home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Text / Edit / Vim / doc / reference.doc < prev    next >
Text File  |  1994-08-14  |  211KB  |  5,014 lines

  1.  
  2.  
  3.  
  4.                 Vim reference manual
  5.                       
  6.                  By Bram Moolenaar
  7.                       
  8.                 version 3.0
  9.                       
  10.  
  11. There is a contents listing at the end of this document.
  12.  
  13. The commands and options for multiple windows and buffers are explained in a
  14. separate document: windows.doc
  15.  
  16.  
  17.  
  18.     1. Introduction
  19.  
  20. Vim stands for Vi IMproved. It used to be Vi IMitation, but that does not
  21. really cover it anymore. Vim is a text editor which includes almost all the
  22. commands from the Unix program "Vi" (and a lot new ones). It is very useful
  23. for editing programs and other ASCII text. All commands are given with the
  24. keyboard. There is no mouse support and there are no menus. This gives the
  25. advantage that you can keep your fingers on the keyboard and your eyes on
  26. the screen.
  27.  
  28. Throughout this manual the differences between Vi and Vim are mentioned in 
  29. curly braces. Read the file "difference.doc" for a summary of the 
  30. differences.
  31.  
  32. This manual refers to Vim on the Commodore Amiga computer. On other 
  33. computers and on terminals there may be small differences. For MSDOS this 
  34. is documented in msdos.doc. For UNIX this is in unix.doc.
  35.  
  36. This manual is a reference for all the Vim commands and options. A basic
  37. knowledge of "Vi" is assumed. A summary of this manual can be found in the 
  38. file vim.hlp. It can be accessed from within Vim with the <HELP> key (in 
  39. MSDOS <F1>) and with the command ":help". The 'helpfile' option can be 
  40. set to the name of the help file, so you can put it in any place you like.
  41.  
  42.  
  43.     2. Notation
  44.  
  45. []        Characters in square brackets are optional.
  46.  
  47. [count]        An optional number that may precede the command to multiply
  48.         or iterate the command. If no number is given a count of one
  49.         is used, unless otherwise noted. Note that in this manual
  50.         the [count] is not mentioned in the description of the
  51.         command, but only in the explanation. This was done to make
  52.         the commands easier to lookup. If the "sc" option is on, the
  53.         (partially) entered count is shown at the bottom of the
  54.         window. You can use <DEL> to erase the last digit.
  55.  
  56. ["x]        An optional register designation where text can be stored.
  57.         The x is a single character between <a> and <z> or <A> and
  58.         <Z> or <">, and in some cases (with the put command) between
  59.         <0> and <9>, <%>, <:> or <.>. The uppercase and lower case
  60.         letter designate the same register, but the lower case letter
  61.         is used to overwrite the previous register contents, while the
  62.         uppercase letter is used to append to the previous register
  63.         contents. Without the ""x" or with """" the stored text is
  64.         put into the unnamed register. See also "Copying and moving
  65.         text".
  66.  
  67. {}        Curly braces denote parts of the command which must appear, 
  68.         but can take a number of different values. The differences 
  69.         between Vim and Vi are also given in curly braces (this will 
  70.         be clear from the context).
  71.  
  72. {motion}    A command that moves the cursor. They are listed in chapter 
  73.         6. This is used after an "operator" command to move over the 
  74.         text that is to be operated upon. If the motion includes a 
  75.         count and the operator also had a count, the two counts are 
  76.         multiplied. For example: "2d3w" deletes six words.
  77.  
  78. {visual}    A piece of text that is started with the "v", "V" or CTRL-V
  79.         command and ended by the cursor position. This is used
  80.         before an "operator" to highlight the text that is to be
  81.         operated upon. See the chapter on Visual mode.
  82.  
  83. <character>    A special character from the table below or a single ASCII
  84.         character.
  85.  
  86. <char1-char2>    A single character from the range <char1> to <char2>. For
  87.         example: <a-z> is a lower case letter. Multiple ranges may be
  88.         concatenated. For example: <a-zA-Z0-9> is any alphanumeric
  89.         character.
  90.  
  91. CTRL-<char>    <char> typed as a control character, that is, typing <char>
  92.         while holding the CTRL key down. The case of <char> does not
  93.         matter, thus CTRL-A and CTRL-a are equivalent.
  94.  
  95. 'option'    An option, or parameter, that can be set to a value is
  96.         enclosed in single quotes. See chapter 19.
  97.  
  98. "command"    In examples the commands you can type are enclosed in double
  99.         quotes.
  100.  
  101.  
  102. notation    meaning             equivalent decimal value
  103. -----------------------------------------------------------------------
  104. <NUL>        zero            CTRL_@  000 (internally 010)
  105. <BELL>      bell            CTRL-G    007
  106. <BS>        backspace        CTRL-H    008
  107. <TAB>       tab            CTRL-I    009
  108. <LF>        linefeed        CTRL-J    010
  109. <FF>        formfeed        CTRL-L    012
  110. <CR>        carriage return        CTRL-M    013
  111. <ESC>       escape            CTRL-[    027
  112. <SPACE>        space                032
  113. <DEL>       delete                127
  114. <C_UP>        cursor-up            128 (msdos: 176)
  115. <C_DOWN>    cursor-down            129 (msdos: 177)
  116. <C_LEFT>    cursor-left            130 (msdos: 178)
  117. <C_RIGHT>    cursor-right            131 (msdos: 179)
  118. <SC_UP>        shift-cursor-up            132 (msdos: 180)
  119. <SC_DOWN>    shift-cursor-down        133 (msdos: 181)
  120. <SC_LEFT>    shift-cursor-left        134 (msdos: 182)
  121. <SC_RIGHT>    shift-cursor-right        135 (msdos: 183)
  122. <F1> - <F10>    function keys 1 to 10        136 - 145 (msdos: 184 - 193)
  123. <SF1> - <SF10>    shift-function keys 1 to 10    146 - 155 (msdos: 194 - 203)
  124. HELP>        help key            156 (msdos: 204)
  125. <UNDO>        undo key            157 (msdos: 205)
  126. -----------------------------------------------------------------------
  127. Note: The shifted cursor keys, the help key and the undo key are only
  128. available on a few terminals. On some terminals the function keys 11 to 20
  129. are used instead of the shifted function keys. On the Amiga shifted function
  130. key 10 produces a code (CSI) that is also used by key sequences. It will be
  131. recognized only after typing another key.
  132.  
  133.  
  134.     3. Starting Vim
  135.  
  136. 3.1 Command line
  137.  
  138. Most often Vim is started to edit a single file with the command
  139.  
  140.     vim file
  141.  
  142. More generally Vim is started with:
  143.  
  144.     vim [options] [filelist]
  145.  
  146. If the filelist is missing, the editor will start with an empty buffer.
  147. Otherwise exactly one out of the following three may be used to choose one
  148. or more files to be edited.
  149.  
  150. file ..        A list of file names. The first one will be the current file 
  151.         and read into the buffer. The cursor will be positioned on 
  152.         the first line of the buffer.
  153.  
  154. -t {tag}    A tag. "tag" is looked up in the tags file, the associated 
  155.         file becomes the current file and the associated command is 
  156.         executed. Mostly this is used for C programs. In that case 
  157.         "tag" should be a function name. The effect is that the file 
  158.         containing that function becomes the current file and the 
  159.         cursor is positioned on the start of the function (see the 
  160.         section "tag searches").
  161.  
  162. -e [errorfile]    QuickFix mode. The file with the name [errorfile] is read
  163.         and the first error is displayed. If [errorfile] is not
  164.         given, the 'errorfile' option is used for the file name
  165.         (default "AztecC.Err" for the Amiga, "errors" for other
  166.         systems). See section 5.5: "using the QuickFix mode".
  167.  
  168. The options, if present, must precede the filelist. The options may be given 
  169. in any order.
  170.  
  171. +[num]        The cursor will be positioned on line "num" for the first
  172.         file being edited. If "num" is missing, the cursor will be
  173.         positioned on the last line.
  174.  
  175. +/{pat}        The cursor will be positioned on the first line containing
  176.         "pat" in the first file being edited (see the section
  177.         "pattern searches" for the available search patterns).
  178.  
  179. +{command}
  180. -c {command}    "command" will be executed after the first file has been
  181.         read. "command" is interpreted as an Ex command. If the
  182.         "command" contains spaces it must be enclosed in double
  183.         quotes (this depends on the shell that is used). Example:
  184.         vim "+set si" main.c
  185.  
  186. -r        Recovery mode. The swap file is read to recover a 
  187.         crashed editing session. See the chapter "Recovery after a
  188.         crash".
  189.  
  190. -v        View mode. The 'readonly' option will be set and no 
  191.         swap file will be written (see -n below). You can 
  192.         still edit the buffer, but will be prevented from 
  193.         accidentally overwriting a file. If you forgot that you are 
  194.         in View mode and did make some changes, you can overwrite 
  195.         a file by adding an exclamation mark to the Ex command, as in 
  196.         ":w!". The 'readonly' option can be reset with ":set noro" 
  197.         (see the options chapter). Calling the executable "view" 
  198.         has the same effect as the -v option. If your system does 
  199.         not support links and you do not want to have the executable 
  200.         twice you could make an alias: "alias view vim -v".
  201.  
  202. -b        Binary mode. The 'textauto', 'textmode' and 'expandtab'
  203.         options will be reset. The 'textwidth' option is set to 0.
  204.         'modelines' is set to 0. The 'binary' option is set. This is
  205.         done after reading the .vimrc/.exrc files but before reading
  206.         a file. See also 5.6: "Editing binary files".
  207.  
  208. -n        No swap file will be used. Recovery after a crash will be
  209.         impossible. Handy if you want to view or edit a file on a
  210.         very slow medium (e.g. floppy). Can also be done with ":set
  211.         uc=0". You can switch it on again by setting the 'uc' option
  212.         to some value, e.g. ":set uc=100". Any files already being
  213.         edited will not be affected by this.
  214.  
  215. -o[N]        Open N windows. If [N] is not given, one window is opened
  216.         for every file given as argument. If there is not enough
  217.         room, only the first few files get a window. If there are
  218.         more windows than arguments, the last few windows will be
  219.         editing an empty file.
  220.  
  221. -T {terminal}    Set the terminal type to "terminal". This influences the 
  222.         codes that Vim will send to your terminal. This is normally 
  223.         not needed, because Vim will be able to find out what type 
  224.         of terminal you are using (See chapter 20).
  225.  
  226. -d {device}    Amiga only: The "device" is opened to be used for editing.
  227.         Normally you would use this to set the window position and
  228.         size: "-d con:x/y/width/height", e.g.
  229.         "-d con:30/10/600/150". But you can also use it to start
  230.         editing on another device, e.g. AUX:.
  231.  
  232. -x        Amiga only: Do not restart Vim to open a new window. This
  233.         option should be used when Vim is started by a program that
  234.         will wait for the edit session to finish (e.g. mail or
  235.         readnews). See section 3.3.
  236.  
  237. -s {scriptin}    The script file "scriptin" is read. The characters in the 
  238.         file are interpreted as if you had typed them. The same can 
  239.         be done with the command ":source! {scriptin}". If the end 
  240.         of the file is reached before the editor exits, further 
  241.         characters are read from the keyboard. See also the section 
  242.         "complex repeats".
  243.  
  244. -w {scriptout}    All the characters that you type are recorded in the file
  245.         "scriptout", until you exit Vim. This is useful if you want 
  246.         to create a script file to be used with "vim -s" or 
  247.         ":source!". See also the section "complex repeats".
  248.  
  249. Example for using a script file to change a name in several files:
  250.     Create a file "subs.vi" containing substitute commands and a :wq
  251.     command:
  252.  
  253.         :%s/Jones/Smith/g
  254.         :%s/Allen/Peter/g
  255.         :wq
  256.  
  257.     Execute Vim on all files you want to change:
  258.  
  259.         foreach i ( *.let ) vim -s subs.vi $i
  260.  
  261. If the executable is called "view" Vim will start in Readonly mode. This is 
  262. useful if you can make a hard or symbolic link from "view" to "vim".
  263. Starting in Readonly mode can also be done with "vim -v". 
  264.  
  265.  
  266. 3.2 Workbench (Amiga only)
  267.  
  268. Vim can be started from the workbench by clicking on its icon twice. It will
  269. then start with an empty buffer.
  270.  
  271. Vim can be started to edit one or more files by using a "Project" icon. The
  272. "Default Tool" of the icon must be the full pathname of the Vim executable. 
  273. The name of the ".info" file must be the same as the name of the text file. 
  274. By clicking on this icon twice, Vim will be started with the filename as 
  275. current filename, which will be read into the buffer (if it exists). You can 
  276. edit multiple files by pressing the shift key while clicking on icons, and 
  277. clicking twice on the last one. The "Default Tool" for all these icons must 
  278. be the same.
  279.  
  280. It is not possible to give arguments to Vim, other than filenames, from the
  281. workbench.
  282.  
  283.  
  284. 3.3 Vim window (Amiga only)
  285.  
  286. Vim will run in the CLI window where it was started. If Vim was started with 
  287. the "run" or "runback" command, or if Vim was started from the workbench, it 
  288. will open a window of its own.
  289.  
  290. Technical detail:
  291.     To open the new window a little trick is used. As soon as Vim 
  292.     recognizes that it does not run in a normal CLI window, it will 
  293.     create a script file in t:. This script file contains the same 
  294.     command as how Vim was started, and an "endcli" command. This script 
  295.     file is then executed with a "newcli" command (the "c:run" and 
  296.     "c:newcli" commands are required for this to work). The script file 
  297.     will hang around until reboot, or until you delete it. This method 
  298.     is required to get the ":sh" and ":!" commands to work correctly. 
  299.     But when Vim was started with the -e option (Quickfix mode) or with 
  300.     the -x option, this method is not used. The reason for this is that 
  301.     when a compiler starts Vim with the -e option it will wait for a 
  302.     return code. With the script trick the compiler cannot get the 
  303.     return code. The -x option can be used when Vim is started by a mail 
  304.     program which also waits for the edit session to finish. As a 
  305.     consequence the ":sh" and ":!" commands are not available when the 
  306.     -e or -x option is used.
  307.  
  308. Vim will automatically recognize the window size and react to window 
  309. resizing. Under Amiga DOS 1.3 it is advised to use the fastfonts program 
  310. "FF" to speed up display redrawing.
  311.  
  312.  
  313. 3.4 Initialization
  314.  
  315. When Vim starts running it does initializations in the following order. If
  316. an environment variable is used, it is executed as a single Ex command line.
  317. Multiple commands must be separated with <|> or <LF>. If a file is used,
  318. each line is executed as an Ex command line.
  319.  
  320. 1.  Four places are searched for initializations. The first that exists is 
  321.     used, the others are ignored.
  322.      1. The environment variable VIMINIT
  323.      2. The file "s:.vimrc" (for Unix: "$HOME/.vimrc")
  324.      3. The environment variable EXINIT
  325.      4. The file "s:.exrc" (for Unix: "$HOME/.exrc")
  326.  
  327. 2.  If the 'exrc' option is set (default is 'noexrc'), the current directory
  328.     is searched for two files. The first that exists is used, the other is
  329.     ignored.
  330.      1. The file ".vimrc"
  331.      2. The file ".exrc"
  332.  
  333. 3.  The environment variable SHELL, if it exists, is used to set the 
  334.     'shell' option. With MSDOS the COMPSPEC variable is used if SHELL does
  335.     not exist. The 'shellpipe' option is set according to the name of the
  336.     shell.
  337.  
  338. 4.  The environment variable TERM, if it exists, is used to set the 'term'
  339.     option.
  340.  
  341. The first can be used to set your default settings and mappings for all edit 
  342. sessions. The second one for sessions in a certain directory (note that the
  343. 'exrc' option is default off). See the section "Saving settings" for how to
  344. create a file with commands to recreate the current settings.
  345.  
  346. If the VIMINIT environment variable or ".vimrc" exist the EXINIT and ".exrc" 
  347. are skipped. This can be used to initialize Vim without interfering with 
  348. another version of Vi.
  349.  
  350. On the Amiga two types of environment variables exist. The ones set with the
  351. DOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3 
  352. manual. The environment variables set with the old Manx Set command (before 
  353. version 5.0) are not recognized.
  354.  
  355. On MS-DOS systems Vim assumes that all the "_vimrc" and "_exrc" files have
  356. <CR><LF> pairs as line separators. This will give problems if you have a
  357. file with only <LF>s and have a line like ":map xx yy^M". The trailing ^M
  358. will be ignored.
  359.  
  360. While reading the ".vimrc" or the ".exrc" file in the current directory some
  361. commands can be disabled for security reasons by setting the 'secure'
  362. option. Otherwise it would be possible to create a .exrc that contains nasty
  363. commands, which another user may automatically execute when he starts Vim it
  364. that directory. The disabled commands are the ones that start a shell and
  365. the ones that write to a file. The ":map" commands are echoed, so you can
  366. see which keys are being mapped.
  367.  
  368. You can reset the 'secure' option in the EXINIT or VIMINIT environment
  369. variable or in the global ".exrc" or ".vimrc" file. This is not possible in
  370. ".vimrc" or ".exrc" in the current directory, for obvious reasons.
  371.  
  372. On unix systems this only happens if you are not the owner of the ".vimrc" 
  373. or ".exrc" file. Warning: If you unpack an archive that contains a .exrc 
  374. file, it will be owned by you. You won't have the security protection. Check 
  375. the .exrc file before you start Vim in that directory, or reset the 'exrc' 
  376. option. 
  377.  
  378.  
  379. 3.5 Suspending
  380.  
  381. CTRL-Z                Suspend the editor. Same as ":stop".
  382.  
  383. :sus[pend][!]        or
  384. :st[op][!]            Suspend the editor. If the <!> is not given,
  385.                 the buffer was changed, autowrite is set and 
  386.                 a filename is known, the buffer will be 
  387.                 written.
  388.  
  389. On many UNIX systems it is possible to suspend Vim with CTRL-Z. This is only 
  390. possible in Command mode (see next chapter). Vim will continue if you make it 
  391. the foreground job again. On other systems CTRL-Z will start a new shell. 
  392. This is the same as the ":sh" command. Vim will continue if you exit from the 
  393. shell.
  394.  
  395.  
  396.     4. Modes
  397.  
  398. 4.1 Introduction
  399.  
  400. Vim has four basic modes:
  401.  
  402. Command mode        In Command mode you can enter all the editor
  403.             commands. If you start the editor you are in this 
  404.             mode (unless you have set the 'insertmode' option, 
  405.             see below).
  406.  
  407. Insert mode        In Insert mode the text you type is inserted into the
  408.             buffer. If the 'showmode' option is set (which is
  409.             default), the string "-- INSERT --" is shown at the
  410.             bottom of the window.
  411.  
  412. Replace mode        Replace mode is a special case of Insert mode. You
  413.             can do the same things as in Insert mode, but for 
  414.             each character you enter (except some special 
  415.             characters) one character of the existing text is 
  416.             deleted. If the 'showmode' option is set (which is 
  417.             default), the string "-- REPLACE --" is shown at the 
  418.             bottom of the window.
  419.  
  420. Command_line mode    In Command_line mode you can enter one line of text
  421.             at the bottom of the window. This is for the Ex
  422.             commands <:>, the pattern search commands <?></> and
  423.             the filter command <!>.
  424.  
  425. More explanation on the insert, replace and Command_line mode is further on 
  426. in this chapter.
  427.  
  428.  
  429. 4.2 Switching from mode to mode
  430.  
  431. If for any reason you do not know in which mode you are, you can always get
  432. back to Command mode by typing <ESC> twice. You will know you are back in
  433. Command mode when you see the screen flash or hear the bell after you type
  434. <ESC>.
  435.  
  436. - go from Command mode to Insert mode by giving one of the commands
  437.   "iIaAoOcCsS".
  438. - go from Command mode to Replace mode with the "R" command (not the "r"
  439.   command!).
  440. - go from Command mode to Command_line mode with the one of the commands
  441.   ":/?!".
  442.  
  443. - go from insert or Replace mode to Command mode with <ESC> (twice in some
  444.   rare cases).
  445. - go from Command_line mode to Command mode by:
  446.    - hitting <CR> or <LF>, which causes the entered command to be executed
  447.    - deleting the complete line (e.g. with CTRL-U) and giving a final <BS>
  448.    - hitting CTRL-C or <ESC>, which quits the command line without executing
  449.      the command.
  450.   In the last case <ESC> may be the character defined with the 'wildchar'
  451.   option, and start command line completion. You can ignore that and type
  452.   <ESC> again. {vi: when hitting <ESC> the command line is executed. This is
  453.   unexpected for most people, therefore it was changed in Vim. But when the
  454.   <ESC> is part of a mapping the command line is executed. If you want the
  455.   vi behaviour also when typing <ESC> use ":cmap ^V<ESC> ^V^M"}
  456.  
  457. If the 'insertmode' option is set, editing a file will start in Insert mode.
  458.  
  459.  
  460. 4.3 Insert and Replace mode
  461.  
  462. 4.3.1 special keys
  463.  
  464. In insert and Replace mode the following characters have a special meaning,
  465. other characters are inserted directly. To insert one of these special
  466. characters into the buffer, precede it with CTRL-V. To insert a <NUL> 
  467. character use "CTRL-V CTRL-@" or "CTRL-V 000". On some systems you have to
  468. use "CTRL-V 003" to insert a CTRL-C.
  469.  
  470. char        action
  471. -----------------------------------------------------------------------
  472. CTRL-@        Insert previously inserted text and stop insert. {Vi: only
  473.         when typed as first char, only up to 128 chars}
  474. CTRL-A        Insert previously inserted text. {not in Vi}
  475. CTRL-B        Toggle the 'revins' option (B for Backwards). {not in Vi}
  476. CTRL-C        Quit insert mode, back to command mode. Do not check for
  477.         abbreviations.
  478. CTRL-D        Delete one shiftwidth of indent at the start of the current 
  479.         line. See also 'shiftround' option. When preceded with <^>
  480.         or <0> delete all indent in the current line. With <^> the
  481.         indent is restored in the next line. This is useful when
  482.         inserting a label. {Vi: CTRL-D works only when used after
  483.         autoindent}
  484. CTRL-E        Insert the character which is below the cursor. {not in Vi}
  485. CTRL-H <BS>    Delete the character before the cursor (see below). {Vi: 
  486.         does not delete autoindents}
  487. CTRL-I <TAB>    Insert a tab. If the 'expandtab' option is on, the
  488.         equivalent number of spaces is inserted (use CTRL-V <TAB> to
  489.         avoid the expansion). See also the 'smarttab' option, section
  490.         4.3.4.
  491. CTRL-J <LF>    Begin new line.
  492. CTRL-K {char1} {char2}
  493.         Enter digraph (see 4.7). {not in Vi}
  494. CTRL-M <CR>    Begin new line.
  495. CTRL-N        Find next keyword (see 4.3.7). {not in Vi}
  496. CTRL-O        Execute one Command mode command. See below. {not in Vi}
  497. CTRL-P        Find previous keyword (see 4.3.7). {not in Vi}
  498. CTRL-R <0-9a-z"%:>
  499.         Insert the contents of a numbered or named register. The
  500.         text is inserted as if you typed it, but mappings and
  501.         abbreviations are not used. If you have options like
  502.         'textwidht' or 'autoindent' set, this will influence what
  503.         will be inserted. Use <"> for the unnamed register,
  504.         containing the text of the last delete or yank. Use <%> for
  505.         the current file name.  Use <:> for the last command line. See
  506.         the chapter on copying and moving text about registers. {<%>,
  507.         <"> and <:> not in Vi}
  508. CTRL-T        Insert one shiftwidth of indent at the start of the current 
  509.         line. See also 'shiftround' option. {Vi: only when in 
  510.         autoindent}
  511. CTRL-U        Delete all entered characters in the current line (see 
  512.         below).
  513. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  514.         decimal value of a single byte. The non-digit and the three
  515.         digits are not considered for mapping. {Vi: no decimal byte
  516.         entry}
  517. CTRL-W        Delete the word before the cursor (see below). See the 
  518.         section "word motions" for the definition of a word.
  519. CTRL-Y        Insert the character which is above the cursor. {not in Vi}
  520. CTRL-[ or <ESC>    End insert or Replace mode, back to Command mode.
  521. <DEL>        Same as CTRL-H <BS>
  522. -----------------------------------------------------------------------
  523.  
  524. The effect of the <BS>, <DEL>, CTRL-W and CTRL-U depends on the 'backspace' 
  525. option (unless 'revins' is set):
  526.  
  527. backspace    action
  528.  option
  529.    0       delete stops in column 1 and start position of insert
  530.    1       delete stops at start position of insert
  531.    2       delete always, CTRL-W and CTRL-U stop once at start position of 
  532.           insert
  533.  
  534. If the 'backspace' option is non-zero and the cursor is in column 1 when one 
  535. of the three keys is used, the current line is joined with the previous 
  536. line. This effectively deletes the newline in front of the cursor. {Vi: does 
  537. not cross lines, does not delete past start position of insert}
  538.  
  539. With CTRL-V followed by one, two or three digits you can enter the decimal 
  540. value of a byte, except 10. Normally CTRL-V is followed by three digits. The 
  541. formed byte is inserted as soon as you type the third digit. If you type 
  542. only one or two digits and then a non-digit, the decimal value of those one 
  543. or two digits form the byte. After that the non-digit is dealt with in the 
  544. normal way. If you enter a value of 10, it will end up in the file as a 0.
  545. The 10 is a <LF>, which is used internally to represent the <NUL> character.
  546. When writing the buffer to a file the <LF> character is translated into
  547. <NUL>. The <LF> character is written at the end of each line. Thus if you
  548. want to insert a <LF> character in a file you will have to make a line
  549. break.
  550.  
  551.  
  552. 4.3.2 special special keys
  553.  
  554. The following keys are special. They stop the current insert, do something 
  555. and then restart insertion. This means you can do something without getting 
  556. out of Insert mode. This is very handy if you prefer to use the Insert mode 
  557. all the time, just like editors that don't have a separate Command mode. You 
  558. may also want to set the 'backspace' option to 2 and set the 'insertmode' 
  559. option. You can use CTRL-O if you want to map a function key to a command.
  560.  
  561. The changes (inserted or deleted characters) before and after these keys can 
  562. be undone separately. Only the last change can be redone and always behaves 
  563. like an "i" command.
  564.  
  565. char        action
  566. -----------------------------------------------------------------------
  567. <C_UP>        cursor one line up
  568. <C_DOWN>    cursor one line down
  569. <C_LEFT>    cursor one character left
  570. <C_RIGHT>    cursor one character right
  571. <SC_UP>        move window one page up
  572. <SC_DOWN>    move window one page down
  573. <SC_LEFT>    cursor one word back (like "b" command)
  574. <SC_RIGHT>    cursor one word forward (like "w" command)
  575. CTRL-O        execute one command and return to Insert mode
  576. -----------------------------------------------------------------------
  577.  
  578. The CTRL-O command has one side effect: If the cursor was beyond the end of 
  579. the line it will be put on the last character in the line.
  580. The shifted cursor keys are not available on all terminals.
  581.  
  582. When the 'whichwrap' option is set appropriately, the <C_LEFT> and <C_RIGHT>
  583. keys on the first/last character in the line make the cursor wrap to the
  584. previous/next line.
  585.  
  586.  
  587. 4.3.3 'textwidth' and 'wrapmargin' option
  588.  
  589. The 'textwidth' option can be used to automatically break a line before it 
  590. gets too long. Set the 'textwidth' option to the desired maximum line 
  591. length. If you then type more characters (not spaces or tabs), the 
  592. last word will be put on a new line (unless it is the only word on the 
  593. line). If you set 'textwidth' to 0, this feature is disabled.
  594.  
  595. The 'wrapmargin' option does almost the same. The difference is that
  596. 'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
  597. screen. When using 'wrapmargin' this is equal to using 'textwidth' with a
  598. value equal to (columns - 'wrapmargin'), where columns is the width of the
  599. screen.
  600.  
  601. When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
  602.  
  603. The line is only broken automatically when using insert mode, or when
  604. appending to a line. When in replace mode and the line length is not
  605. changed, the line will not be broken.
  606.  
  607. If you want to format a block of text you can use the "Q" operator. Type "Q" 
  608. and a movement command to move the cursor to the end of the block. In many 
  609. cases the command "Q}" will do what you want (format until the end of 
  610. paragraph). Or you can use visual mode: hit "v", move to the end of the
  611. block and hit "Q".
  612.  
  613.  
  614. 4.3.4 'expandtab' and 'smarttab' options
  615.  
  616. If the 'expandtab' option is set, spaces will be used to fill the amount of
  617. whitespace of the tab. If you want to enter a real <TAB> type CTRL-V first.
  618. The 'expandtab' option is default off. Note that in Replace mode a single
  619. character is replaced by several spaces. The result of this is that the
  620. number of characters in the line increases. Backspacing will delete one
  621. space at a time. The original text will be put back in a place where you
  622. would not expect it. {not in Vi}
  623.  
  624. When the 'smarttab' option is set a TAB in front of a line inserts
  625. 'shiftwidth' positions, 'tabstop' in other places. This means that often
  626. spaces instead of a TAB character is inserted. When not set a TAB always
  627. inserts 'tabstop' positions, 'shiftwidth' is only used for ">>" and the like.
  628. {not in Vi}
  629.  
  630.  
  631. 4.3.5 typing backwards
  632.  
  633. If the 'revins' (reverse insert) option is set, inserting happens backwards.
  634. This can be used to type Hebrew. When inserting characters the cursor is not
  635. moved and the text moves rightwards. A <BS> deletes the character under the
  636. cursor. CTRL-W and CTRL-U also work in the opposite direction. <BS>, CTRL-W
  637. and CTRL-U do not stop at the start of insert or end of line, no matter how
  638. the 'backspace' option is set.
  639.  
  640. In Replace mode the cursor is moved leftwards. <BS> will restore the
  641. character right of the cursor.
  642.  
  643. In insert or Replace mode the 'revins' option can be toggled with CTRL-B.
  644.  
  645. If the 'showmode' option is set, "-- REVERSE INSERT --" or
  646. "-- REVERSE REPLACE --" will be shown in the status line.
  647.  
  648.  
  649. 4.3.6 Replace mode
  650.  
  651. In Replace mode one character in the line is deleted for every character you 
  652. type. If there is no character to delete (at the end of the line), the 
  653. typed character is appended (as in Insert mode). Thus the number of 
  654. characters in a line stays the same until you get to the end of the line.
  655.  
  656. Be careful with <TAB> characters. If you type a normal printing character in 
  657. its place, the number of characters is still the same, but the number of 
  658. columns will become smaller.
  659.  
  660. If you delete characters in Replace mode (with <BS>, <DEL>, CTRL-W or
  661. CTRL-U), you really delete your changes. The characters that were replaced
  662. are restored. If you had typed past the existing text, the characters you
  663. added are deleted.
  664.     All this only works in the current line. If you have started a new line
  665. (replaced a character with a <CR>) Vim no longer remembers what happened in
  666. the previous line. If you backspace over the newline (only possible if the
  667. 'backspace' option is non-zero), the two lines will be joined again, but
  668. typing further backspaces will not restore the original text. Only the
  669. cursor is moved.
  670.     If the 'expandtab' option is set, a <TAB> will replace one character
  671. with several spaces. When backspacing over these spaces, the original text
  672. will appear in a position where you would not expect it.
  673.  
  674.  
  675. 4.3.7 Keyword completion
  676.  
  677. In insert and replace mode the keys CTRL-N and CTRL-P can be used to
  678. complete the keyword that is in front of the cursor. This is useful if you
  679. are writing a program that has complicated variable names, and you want to
  680. copy a name from the text before of after the cursor.
  681.  
  682. If there is an identifier in front of the cursor (a name made out of
  683. alphanumeric characters and <_>) it is used as the search pattern, with "\<"
  684. prepended (meaning: start of a word). Otherwise "\<[a-zA-Z_]" is used as
  685. search pattern (start of any identifier).
  686.  
  687. With CTRL-N (next) the search goes forward, with CTRL-P (previous) the
  688. search goes backward. The first time the search starts where the cursor is.
  689. The next times the search starts at the last found position. If you type any
  690. other character than CTRL-P or CTRL-N the current text is accepted and the
  691. search pattern is forgotten.
  692.  
  693. If the search found a match, it is inserted at the cursor position. Any
  694. previous match is replaced. If no match was found, Vim will beep.
  695.  
  696. If there is not a valid identifier character before the cursor, any
  697. identifier is matched.
  698.     eg. to get:
  699.         printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
  700.     just type:
  701.         printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
  702.  
  703. Multiple repeats of the same completion are skipped.
  704.  
  705. If there is only one completion found, then a second CTRL-P or CTRL-N will
  706. give the message 'No other matches'.
  707.  
  708. If the only match in the file is an exact match, where no extra characters
  709. would be typed, then the message 'Exact match only' is given (this is also
  710. useful for checking that you typed the symbol correctly).
  711.  
  712. The mode (--INSERT--) is shown, unless there is another more important
  713. message (eg Pattern not found).  This other message will stay until another
  714. key is hit, and then the mode is shown again.
  715.  
  716. Only matches where something extra will be added are used.
  717.     eg. to get:
  718.         printf("name = %s\n", name);
  719.     just type:
  720.         printf("name = %s\n", n^P);
  721. The 'n' in '\n' is skipped.
  722.  
  723.  
  724. 4.4 Command_line mode
  725.  
  726. Command_line mode is used to enter Ex commands <:>, search patterns </><?>
  727. and filter commands <!>.
  728.  
  729.  
  730. 4.4.1 Command line editing
  731.  
  732. Normal characters are inserted in front of the cursor position. You can move
  733. around in the command line with the left and right cursor keys. {Vi: can 
  734. only alter the last character in the line}
  735.  
  736. The command lines that you enter are remembered in a history table. You can
  737. recall them with the up and down cursor keys. Use the 'history' option to 
  738. set the number of lines that are remembered (default 20).
  739.  
  740. There is an automatic completion of names on the command line, see 4.4.2.
  741.  
  742. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  743.         decimal value of a single byte. The non-digit and the three
  744.         digits are not considered for mapping. This works the same
  745.         way as in Insert mode (see above).
  746. <C_LEFT>    cursor left
  747. <C_RIGHT>    cursor right
  748. <SC_LEFT>    cursor one word left
  749. <SC_RIGHT>    cursor one word right
  750. CTRL-B        cursor to begin of command line
  751. CTRL-E        cursor to end of command line
  752.  
  753. <BS>        delete the character in front of the cursor
  754. <DEL>        delete the character under the cursor (at end of line:
  755.         character in front of the cursor)
  756. CTRL-W        delete the word in front of the cursor
  757. CTRL-U        remove all characters
  758.  
  759.         Note: if the command line becomes empty with one of the
  760.         delete commands, command line mode is quit.
  761.  
  762. {char1} <BS> {char2}    or
  763. CTRL-K {char1} {char2}
  764.         enter digraph (see 4.7). {not in Vi}
  765.  
  766. <CR> or <LF>    start entered command
  767. <ESC>        when typed: quit command line without executing
  768.         in macros: start entered command
  769. CTRL-C        quit command line without executing
  770.  
  771. <C_UP>        recall older command line from history
  772. <C_DOWN>    recall more recent command line from history
  773.  
  774. <SC_UP>        recall older command line from history, which begin matches 
  775.         the current command line (see below).
  776. <SC_DOWN>    recall more recent command line from history, which begin 
  777.         matches the current command line (see below).
  778.  
  779. CTRL-D        command line completion (see 4.4.2)
  780. 'wildchar' option
  781.         command line completion (see 4.4.2)
  782. CTRL-N        command line completion (see 4.4.2)
  783. CTRL-P        command line completion (see 4.4.2)
  784. CTRL-A        command line completion (see 4.4.2)
  785. CTRL-L        command line completion (see 4.4.2)
  786.  
  787. The <SC_UP> and <SC_DOWN> keys take the current command line as search 
  788. string. The beginning of the next/previous command lines are compared against 
  789. this string. The fist line that matches is the new command line. When typing 
  790. these two keys repeatedly, the same string is used again. For example this 
  791. can be used to find the previous substitute command: Type ":s" and then 
  792. <SC_UP>. The same could be done by typing <C_UP> a number of times until the 
  793. desired command line is shown. (Note: the shifted arrow keys do not work on
  794. all terminals) 
  795.  
  796.  
  797. 4.4.2 Command line completion
  798.  
  799. When editing the command line a few commands can be used to complete the
  800. word before the cursor. This is available for:
  801.  
  802. - Command names, at the start of the command line. Works always.
  803. - tags, only after the ":tag" command.
  804. - file names, only after a command that accepts a file name or a setting for
  805.   an option that can be set to a file name. This is called file name
  806.   completion.
  807. - options, only after the ":set" command.
  808.  
  809. These are the commands that can be used:
  810.  
  811. CTRL-D        List names that match the pattern in front of the cursor.
  812.         When showing file names, directories are highlighted (see
  813.         'highlight' option)
  814. 'wildchar' option
  815.         A match is done on the pattern in front of the cursor. The
  816.         match, or if there are several, the first match, is inserted
  817.         in place of the pattern. (Note: does not work inside a
  818.         macro, because TAB or ESC is mostly used as 'wildchar', and
  819.         these have a special meaning in some macros)
  820.         When typed again, and there were multiple matches, the next
  821.         match is inserted. After the last match the first is used
  822.         again (wrap around).
  823. CTRL-N        After using 'wildchar' which got multiple matches: go to next
  824.         match. Otherwise: Recall more recent command line from history.
  825. CTRL-P        After using 'wildchar' which got multiple matches: go to
  826.         previous match. Otherwise: Recall older command line from
  827.         history.
  828. CTRL-A        All names that match the pattern in front of the cursor are
  829.         inserted.
  830. CTRL-L        A match is done on the pattern in front of the cursor. If
  831.         there is one match, it is inserted in place of the pattern.
  832.         If there are multiple matches the longest common part is
  833.         inserted in place of the pattern.
  834.  
  835. The 'wildchar' option defaults to <TAB> (CTRL-E when compiled with 
  836. COMPATIBLE; in a previous version <ESC> was used). In the pattern standard
  837. wildcards <*> and <?> are accepted. <*> matches any string, <?> matches
  838. exactly one character.
  839.  
  840. For filename completion you can use the 'suffixes' option to set a priority 
  841. between files with almost the same name. If there are multiple matches, 
  842. those files with an extension that is in the 'suffixes' option are ignored.
  843. The default is ".bak.o.h.info.swp", which means that files with the
  844. extensions ".bak", ".o", ".h", ".info" and ".swp" are sometimes ignored. It
  845. is impossible to ignore suffixes with two dots. Examples:
  846.  
  847. pattern:    files:                match:
  848. test*        test.c test.h test.o        test.c
  849. test*        test.h test.o            test.h and test.o
  850. test*        test.i test.h test.c        test.i and test.c
  851.  
  852. If there is more than one matching file (after ignoring the ones matching
  853. the 'suffixes' option) the first file name is inserted. You can see that
  854. there is only one match when you type 'wildchar' twice and the completed
  855. match stays the same. You can get to the other matches by entering
  856. 'wildchar', CTRL-N or CTRL-P. All files are included, also the ones with
  857. extensions matching the 'suffixes' option.
  858.  
  859.  
  860. 4.4.3 Ex command lines
  861.  
  862. The Ex commands have a few specialties:
  863.  
  864. <"> at the start of a line causes the whole line to be ignored. <"> 
  865. after a command causes the rest of the line to be ignored. This can be used 
  866. to add comments. Example:
  867.     :set ai     "set 'autoindent' option
  868. It is not possible to add a comment to a shell command ":!cmd" or to the
  869. ":map" command and friends, because they see the <"> as part of their
  870. argument.
  871.  
  872. <|> can be used to separate commands, so you can give multiple commands in 
  873. one line. The commands ":global", "vglobal" and  ":!" see the <|> as their
  874. argument, and can therefore not be followed by another command. If you want
  875. <|> to be included in a command, precede it with <\>. Note that this is
  876. confusing (inherited from vi). If you give a command with ":!" you don't
  877. have to use a backslash, with ":r !" you have to. And with ":g" the <|> is
  878. included in the command, with ":s" it is not. Examples:
  879.     :!ls | wc        view the output of two commands
  880.     :r !ls \| wc        insert the same output in the text
  881.     :%g/foo/p|>        moves all matching lines one shiftwidth
  882.     :%s/foo/bar/|>        moves one line one shiftwidth
  883. You can also use <LF> to separate commands in the same way as with <|>. But
  884. using <|> is the preferred method.
  885.  
  886. When the character <%> or <#> is used where a filename is expected, they are 
  887. expanded to the current and alternate filename (see the chapter "editing 
  888. files").
  889.  
  890. Embedded spaces in filenames are allowed if one filename is expected as
  891. argument. Trailing spaces will be ignored, unless escaped with a backslash
  892. or CTRL-V. Note that the ":next" command uses spaces to separate file names.
  893. Escape the spaces to include them in a file name. Example:
  894.     :next foo\ bar goes\ to school\ 
  895. starts editing the three files "foo bar", "goes to" and "school ".
  896.  
  897. When you want to use the special characters <"> or  <|> in a command, or want
  898. to use <%> or <#> in a filename, precede them with a backslash. The backslash
  899. is not required in a range and in the ":substitute" command.
  900.  
  901.  
  902. 4.4.4 Ex command line ranges
  903.  
  904. Some Ex commands accept a line range in front of them. This is noted as
  905. [range]. It consists of one or more line specifiers, separated with <,> or 
  906. <;>. When separated with <;> the cursor position will be set to that line 
  907. before interpreting the next line specifier. The default line specifier for 
  908. most commands is the cursor position, but the commands ":write" and 
  909. ":global" have the whole file (1,$) as default. If more line specifiers are 
  910. given than required for the command, the first one(s) will be ignored.
  911.  
  912. Line numbers may be specified with:
  913.     {number}    an absolute line number
  914.     .        the current line
  915.     $        the last line in the file
  916.     %        equal to 1,$ (the entire file)
  917.     't        position of mark t (lower case)
  918.     /{pattern}[/]    the next line where {pattern} matches
  919.     ?{pattern}[?]    the previous line where {pattern} matches
  920.  
  921. Each may be followed (several times) by <+> or <-> and an optional number. 
  922. This number is added or subtracted from the preceding line number. If the 
  923. number is omitted, 1 is used.
  924.  
  925. The "/" and "?" may be preceded with another address. The search starts from
  926. there. The "/" and "?" after {pattern} are required to separate the pattern
  927. from anything that follows.
  928.  
  929. The {number} must be between 0 and the number of lines in the file. A 0 is 
  930. interpreted as a 1, except with the commands tag, pop and read.
  931.  
  932. Examples:
  933.     .+3        three lines below the cursor
  934.     /that/+1    the line below the next line containing "that"
  935.     .,$        from current line until end of file
  936.     0/that        the first line containing "that"
  937.  
  938. Some commands allow for a count after the command. This count is used as the
  939. number of lines to be used, starting with the line given in the last line
  940. specifier (the default is the cursor line). The commands that accept a count
  941. are the ones that use a range but do not have a file name argument (because
  942. a file name can also be a number).
  943.  
  944. Examples:
  945.     :s/x/X/g 5    substitute <x> by <X> in the current line and four
  946.             following lines
  947.     :23d 4        delete lines 23, 24, 25 and 26
  948.  
  949. A range should have the lower line number first. If this is not the case, Vim
  950. will ask you if it should swap the line numbers. This is not done within the
  951. global command ":g".
  952.  
  953. When giving a count before entering ":", this is translated into:
  954.         :.,.+(count - 1)
  955. In words: The 'count' lines at and after the cursor. Example: To delete
  956. three lines:
  957.         3:d<CR>        is translated into: .,.+2d<CR>
  958.  
  959.  
  960. 4.5 The window contents
  961.  
  962. In command and Insert/Replace mode the screen window will show the current
  963. contents of the buffer: What You See Is What You Get. {Vi: when changing 
  964. text a <$> is placed on the last changed character; The window is not always 
  965. updated on slow terminals} Lines longer than the window width will wrap,
  966. unless the 'wrap' option is off (see below). The bottom lines in the window
  967. may start with one of these two characters:
  968.  
  969. <@>     The next line is too long to fit in the window.
  970. <~>    Below the last line in the buffer.
  971.  
  972. If the bottom line is completely filled with <@>, the line that is at the 
  973. top of the window is too long to fit in the window. If the cursor is on this 
  974. line you can't see what you are doing, because this part of the line is not 
  975. shown. However, the part of the line before the <@>s can be edited normally. 
  976. {Vi: gives an "internal error" on lines that do not fit in the window}
  977.  
  978. If the 'wrap' option is off, long lines will not wrap. Only the part that
  979. fits on the screen is shown. If the cursor is moved to a part of the line
  980. that is not shown, the screen is scrolled horizontally. The advantage of
  981. this method is that columns are shown as they are and lines that cannot fit
  982. on the screen can be edited. The disadvantage is that you cannot see all the
  983. characters of a line at once. The 'sidescroll' option can be set to the
  984. minimal number of columns to scroll. {Vi: has no 'wrap' option}
  985.  
  986. All normal ASCII characters are displayed directly on the screen. The <TAB> 
  987. is replaced by the number of spaces that it represents. Other non-printing 
  988. characters are replaced by "^<char>", where <char> is the non-printing 
  989. character with 64 added. Thus character 7 (bell) will be shown as "^G". 
  990. Characters between 127 and 160 are replaced by "~<char>", where <char> is 
  991. the character with 64 subtracted. These characters occupy more than one 
  992. position on the screen. The cursor can only be positioned on the first one.
  993.  
  994. If you set the 'number' option, all lines will be preceded with their 
  995. number.
  996.  
  997. If you set the 'list' option, <TAB> characters will not be shown as several
  998. spaces, but as "^I". A <$> will be placed at the end of the line, so you can
  999. find trailing blanks.
  1000.  
  1001. In Command_line mode only the command line itself is shown correctly. The
  1002. display of the buffer contents is updated as soon as you go back to Command
  1003. mode.
  1004.  
  1005. Some commands hand over the window to external commands (e.g. ":shell" and
  1006. "="). After these commands are finished the window may be clobbered with 
  1007. output from the external command, so it needs to be redrawn. This is also 
  1008. the case if something is displayed on the status line that is longer than 
  1009. the width of the window. If you are expected to have a look at the screen 
  1010. before it is redrawn, you get this message:
  1011.  
  1012.         Press RETURN or enter command to continue
  1013.  
  1014. After you type a key the screen will be redrawn and Vim continues. If you 
  1015. type <CR>, <SP> or <LF> nothing else happens. If you type any other key, it 
  1016. will be interpreted as (the start of) a new command. {Vi: only <:> commands 
  1017. are interpreted}
  1018.  
  1019. The last line of the window is used for status and other messages. The 
  1020. status messages will only be used if an option is on:
  1021.  
  1022. status message            option        default    unix default
  1023. current mode             'showmode'    on        on
  1024. command characters        'showcmd'    on        off
  1025. cursor position            'ruler'        off        off
  1026.  
  1027. The current mode is "-- INSERT --" or "-- REPLACE --". The command 
  1028. characters are those that you typed but were not used yet. {Vi: does not
  1029. show the characters you typed or the cursor position}
  1030.  
  1031. If you have a slow terminal you can switch off the status messages to speed 
  1032. up editing:
  1033.     :set nosc noru nosm
  1034.  
  1035. If there is an error, an error message will be shown for at least one second 
  1036. (in reverse video). {Vi: error messages may be overwritten with other 
  1037. messages before you have a chance to read them}
  1038.  
  1039. Some commands show how many lines were affected. Above which threshold this
  1040. happens can be controlled with the 'report' option (default 2).
  1041.  
  1042. On the Amiga Vim will run in a CLI window. The name Vim and the full name of
  1043. the current filename will be shown in the title bar. When the window is
  1044. resized, Vim will automatically redraw the window. You may make the window as
  1045. small as you like, but if it gets too small not a single line will fit in it.
  1046. Make it at least 40 characters wide to be able to read most messages on the
  1047. last line.
  1048.  
  1049. On most Unix systems window resize works ok.  {Vi: not ok}
  1050.  
  1051.  
  1052. 4.6 Abbreviations
  1053.  
  1054. Abbreviations are used in insert mode, Replace mode and Command_line mode.
  1055. If you enter a word that is an abbreviation, it is replaced by the word it
  1056. stands for. This can be used to save typing for often used long words.
  1057.  
  1058. There are two types of abbreviations: The "full-id" type consists entirely
  1059. of id characters (letters, digits and <_> characters). This is the most
  1060. common abbreviation. The "non-id" type ends in an id character, but all the
  1061. other characters are not id characters. Examples of a "full-id" type are
  1062. "foo" and "c_1". Examples of a "non-id" type are "#i" and "$/7". Examples of
  1063. strings that will not be recognized as an abbreviation are "a.b", "a b" and
  1064. "_$ar".
  1065.  
  1066. The "full-id" abbreviation is recognized if:
  1067. - A character is typed that is not an id character. This can also be
  1068.   the <ESC> that ends insert mode or the <CR> that ends a command.
  1069. - The characters in front of the cursor match the abbreviation.
  1070. - In front of the match is a non-id character, or this is where the line or
  1071.   insertion starts. Exception: when the abbreviation is only one character,
  1072.   it is not recognized if there is a non-id character in front of it, other
  1073.   than a space or a TAB.
  1074.  
  1075. The "non-id" abbreviation is recognized if:
  1076. - A character is typed that is not an id character. This can also be
  1077.   the <ESC> that ends insert mode or the <CR> that ends a command.
  1078. - The characters in front of the cursor match the abbreviation.
  1079. - In front of the match is an id character, or a space or a TAB, or this is
  1080.   where the line or insertion starts.
  1081.  
  1082. Example: ":ab foo four old otters". Note that spaces in the <rhs> are
  1083. allowed and included in the replacement string. If you now insert the word
  1084. "foo" with a space before and after it, it will be replaced by "four old
  1085. otters". If you would type "foobar" or "barfoo" nothing happens.
  1086.  
  1087. To avoid the abbreviation in insert mode type part of the abbreviation, exit
  1088. insert mode with <ESC>, re-enter insert mode with "a" and type the rest. In
  1089. Command_line mode you can type CTRL-V twice somewhere in the abbreviation to
  1090. avoid it to be replaced. A CTRL-V in front of a normal character is mostly
  1091. ignored otherwise.
  1092.  
  1093. There are no default abbreviations.
  1094.  
  1095. Abbreviations are never recursive. You can use ":ab f f-o-o" without any
  1096. problem. But abbreviations can be mapped. {some versions of vi support
  1097. recursive abbreviations, for no apparent reason}
  1098.  
  1099. Abbreviations are disabled if the 'paste' option is set.
  1100.  
  1101. :ab[breviate]        list all abbreviations. The character in the first
  1102.             column indicates the mode where the abbreviation is
  1103.             used: 'i' for insert mode, 'c' for Command_line
  1104.             mode, '!' for both.
  1105.  
  1106. :ab[breviate] <lhs>    list the abbreviations that start with <lhs>
  1107.  
  1108. :ab[breviate] <lhs> <rhs>
  1109.             add abbreviation for <lhs> to <rhs>. If <lhs> already
  1110.             existed it is replaced with the new <rhs>. <rhs> may
  1111.             contain spaces.
  1112.  
  1113. :una[bbreviate] <lhs>    remove abbreviation for <lhs> from the list
  1114.  
  1115. :norea[bbrev] [lhs] [rhs]
  1116.             same as ":ab", but no remapping for this <rhs> {not
  1117.             in Vi}
  1118.  
  1119. :ca[bbrev] [lhs] [rhs]    same as ":ab", but for Command_line mode only. {not
  1120.             in Vi}
  1121.  
  1122. :cuna[bbrev] <lhs>    same as ":una", but for Command_line mode only. {not
  1123.             in Vi}
  1124.  
  1125. :cnorea[bbrev] [lhs] [rhs]
  1126.             same as ":ab", but for Command_line mode only and no
  1127.             remapping for this <rhs> {not in Vi}
  1128.  
  1129. :ia[bbrev] [lhs] [rhs]    same as ":ab", but for insert mode only. {not in Vi}
  1130.  
  1131. :iuna[bbrev] <lhs>    same as ":una", but for insert mode only. {not in
  1132.             Vi}
  1133.  
  1134. :inorea[bbrev] [lhs] [rhs]
  1135.             same as ":ab", but for insert mode only and no
  1136.             remapping for this <rhs> {not in Vi}
  1137.  
  1138.  
  1139. 4.7 Digraphs
  1140.  
  1141. :dig[raphs]        show currently defined digraphs. {not in Vi}
  1142.  
  1143. :dig[raphs] {char1}{char2} {number} ...
  1144.             Add digraph {char1}{char2} to the list. {number} is 
  1145.             the decimal representation of the character.
  1146.  
  1147. Digraphs are used to enter characters that normally cannot be entered by 
  1148. an ordinary keyboard. These are mostly accented characters which have the 
  1149. eighth bit set. The digraphs are easier to remember than the decimal number
  1150. that can be entered with CTRL-V (see above).
  1151.  
  1152. Vim must have been compiled with the 'digraphs' option enabled. If not, the 
  1153. ":digraph" command will display an error message.
  1154.  
  1155. There are two methods to enter digraphs:
  1156.     CTRL-K {char1} {char2}        or
  1157.     {char1} <BS> {char2}
  1158. The first is always available. The second only when the 'digraph' option is 
  1159. set.
  1160.  
  1161. Once you have entered the digraph the character is treated like a normal 
  1162. character, taking up only one character in the file and on the screen. 
  1163. Example:
  1164.     <|> <BS> <|>    will enter the double <|> character (166)
  1165.     <a> <BS> <^>    will enter an <a> with a hat (226)
  1166.     CTRL-K <-> <->    will enter a minus sign (173)
  1167.  
  1168. The default digraphs are listed in the file digraph.doc. They are meant for 
  1169. the Amiga character set, which is some international standard. With another 
  1170. character set they may be illogical.
  1171.  
  1172. For CTRL-K there is one general digraph: CTRL-K <SPACE> {char} will enter
  1173. {char} with the highest bit set. This can be used to enter meta-characters.
  1174.  
  1175. The <ESC> character cannot be part of a digraph. When hitting <ESC> entering
  1176. the digraph is aborted and insert mode too.
  1177.  
  1178. If you accidently typed an <a> that should be an <e>, you will type <a> <BS> 
  1179. <e>. But that is a digraph, so you will not get what you want. To avoid this, 
  1180. use <DEL> instead of <BS>. Or don't set the 'digraph' option and use CTRL-K
  1181. to enter digraphs.
  1182.  
  1183.  
  1184.     5. Editing files
  1185.  
  1186. 5.1 Introduction
  1187.  
  1188. Editing a file with Vim means:
  1189.  
  1190. 1. reading the file into the internal buffer
  1191. 2. changing the buffer with editor commands
  1192. 3. writing the buffer into a file
  1193.  
  1194. As long as you don't write the buffer, the original file remains unchanged. 
  1195. If you start editing a file (read a file into the buffer), the file name is 
  1196. remembered as the "current filename".
  1197.  
  1198. If there already was a current filename, then that one becomes the alternate
  1199. file name. All filenames are remembered in the file list. When you enter a
  1200. filename, for editing (e.g. with ":e filename") or writing (e.g. with (:w
  1201. filename"), the filename is added to the list. You can use this list to
  1202. remember which files you edited and to quickly switch from one file to
  1203. another with the CTRL-^ command (e.g. to copy text). First type the number
  1204. of the file and then hit CTRL-^. {Vi: only one alternate filename}
  1205.  
  1206. In Ex commands (the ones that start with a colon) <%> is replaced by the
  1207. current filename and <#> is replaced by the alternate filename. The older
  1208. alternate filenames are "#1", "#2", etc. "#0" is the same as "#". If a
  1209. "<" is appended to <%>, <#> or "#n" the extension of the file name is
  1210. removed (everything after and including the last '.' in the file name).
  1211.  
  1212.     %        current file name
  1213.     %<        current file name without extension
  1214.     #        alternate file name for current window
  1215.     #<        idem, without extension
  1216.     #31        alternate file number 31
  1217.     #31<        idem, without extension
  1218.  
  1219. CTRL-G        or
  1220. :f[ile]            Prints the current filename (as typed) and the
  1221.             cursor position. {vi does not include column number}
  1222.  
  1223. {count}CTRL-G        Prints the current filename with full path and the
  1224.             cursor position.
  1225.  
  1226. :f[ile] {name}        Sets the current filename to {name}.
  1227.  
  1228. :buffers
  1229. :files            List all the currently known file names. See
  1230.             'windows.doc'. {not in vi}
  1231.  
  1232. Vim will remember the full path name of a file name that you enter. In most
  1233. cases when the file name is displayed only the name you typed is shown, but
  1234. the full path name is being used if you used the ":cd" command.
  1235.  
  1236. If the environment variable 'HOME' is set, and the file name starts with
  1237. that string, it is often displayed with HOME replaced by "~". This was done
  1238. to keep file names short. When reading or writing files the full name is
  1239. still used, the "~" is only used when displaying file names.
  1240.  
  1241. When writing the buffer, the default is to use the current filename. Thus 
  1242. when you give the "ZZ" or ":wq" command, the original file will be 
  1243. overwritten. If you do not want this, the buffer can be written into another 
  1244. file by giving a filename argument to the ":write" command. For example:
  1245.     
  1246.     vim testfile
  1247.     [change the buffer with editor commands]
  1248.     :w newfile
  1249.     :q
  1250.  
  1251. This will create a file "newfile", that is a modified copy of "testfile". 
  1252. The file "testfile" will remain unchanged. Anyway, if the 'backup' option is 
  1253. set, Vim renames the original file before it will be overwritten. You can 
  1254. use this file if you discover that you need the original file. See also the
  1255. 'patchmode' option. The name of the backup file is the same as the original
  1256. file with ".bak" appended. Any <.> is replaced by <_> on MSDOS machines, when
  1257. Vim has detected that an MSDOS-like filesystem is being used (e.g. messydos or
  1258. crossdos) and when the 'shortname' option is set.
  1259.  
  1260. Technical: On the Amiga you can use 30 characters for a file name. But on an 
  1261.        MSDOS-compatible filesystem only 8 plus 3 characters are 
  1262.        available. Vim tries to detect the type of filesystem when it is 
  1263.        creating the .swp file. If an MSDOS-like filesystem is suspected, 
  1264.        a flag is set that has the same effect as setting the 'shortname' 
  1265.        option. This flag will be reset as soon as you start editing a 
  1266.        new file. The flag will be used when making the filename for the 
  1267.        ".swp" and ".bak" files for the current file. But when you are 
  1268.        editing a file in a normal filesystem and write to an MSDOS-like 
  1269.        filesystem the flag will not have been set. In that case the 
  1270.        creation of the ".bak" file may fail and you will get an error 
  1271.        message. Use the 'shortname' option in this case.
  1272.  
  1273. When you started editing without giving a file name, "No File" is displayed in
  1274. messages. If a ":write file" or ":read file" command is used, the file name
  1275. for the current file is set to the file name in that command. This is useful
  1276. when starting Vim without an argument and then doing ":read file" to start
  1277. editing a file. Or when entering text in an empty buffer and then writing it
  1278. to a file. Because the file name was set without really starting to edit that
  1279. file, you are protected from overwriting that file. This is done by setting
  1280. the "notedited" flag. You can see if this flag is set with the CTRL-G or
  1281. ":file" command. It will include "[Not edited]" when the "notedited" flag is
  1282. set. When writing the buffer to the current file name (with ":w!"), the
  1283. "notedited" flag is reset.
  1284.  
  1285. Vim remembers whether you have changed the buffer. You are protected from
  1286. losing the changes you made. If you try to quit without writing, or want to
  1287. start editing another file, this will be refused. In order to overrule this
  1288. protection add a <!> to the command. The changes will then be lost. For
  1289. example: ":q" will not work if the buffer was changed, but ":q!" will. To see
  1290. whether the buffer was changed use the "CTRL-G" command. The message includes
  1291. the string "[Modified]" if the buffer has been changed.
  1292.  
  1293.  
  1294. 5.2 Editing a file
  1295.  
  1296. :e[dit] [+cmd]        Edit the current file, unless changes have been made.
  1297.  
  1298. :e[dit]! [+cmd]        Edit the current file always. Discard any changes to
  1299.             the buffer.
  1300.  
  1301. :e[dit] [+cmd] {file}    Edit {file}, unless changes have been made.
  1302.  
  1303. :e[dit]! [+cmd] {file}    Edit {file} always. Discard any changes to the
  1304.             buffer.
  1305.  
  1306. :e[dit] #[count]        Edit the [count]th alternate filename (as shown by
  1307.                         :files). This command does the same as [count] CTRL-^.
  1308.  
  1309. :ex [+cmd] [file]    Same as :edit. {Vi: go from visual to Ex mode}
  1310.  
  1311. :vi[sual] [+cmd] [file]    Same as :edit. {Vi: go from Ex to Visual mode}
  1312.  
  1313. [count]CTRL-^        Edit [count]th alternate file (equivalent to ":e
  1314.             #[count]"). Without count this gets you to the
  1315.             previously edited file. This is a quick way to
  1316.             toggle between two (or more) files. If the
  1317.             'autowrite' option is set and the buffer was
  1318.             changed, write it.
  1319.  
  1320. ]f
  1321. [f
  1322. gf            Edit the file whose name is under or after the
  1323.             cursor. Mnemonic: "goto file". This fails if the
  1324.             current file cannot be abandoned. {not in Vi}
  1325.  
  1326. :cd            On non-Unix systems: Print the current directory
  1327.             name. On Unix systems: Change the current directory
  1328.             to the home directory.
  1329.  
  1330. :cd {path}        Change the current directory to {path}. Does not
  1331.             change the meaning of an already entered file name,
  1332.             because its full path name is remembered.
  1333.  
  1334. :chd[ir] [path]        Same as :cd.
  1335.  
  1336. :pwd            Print the current directory name. {Vi: no pwd}
  1337.  
  1338. These commands are used to start editing a single file. This means that the
  1339. file is read into the buffer and the current filename is set. You may use the
  1340. ":cd" command to get to another directory, so you will not have to type that 
  1341. directory name in front of the filenames. One warning: After using ":cd" the
  1342. full path name will be used for reading and writing files. On some networked
  1343. file systems this may cause problems. The result of using the full path name
  1344. is that the file names currently in use will remain referring to the same
  1345. file. Example: If you have a file a:test and a directory a:vim the commands
  1346. ":e test" ":cd vim" ":w" will overwrite the file a:test and not write
  1347. a:vim/test. But if you do ":w test" the file a:vim/test will be written,
  1348. because you gave a new file name and did not refer to a file name before the
  1349. ":cd".
  1350.  
  1351. You can use the ":e!" command if you messed up the buffer and want to start 
  1352. all over again. The ":e" command is only useful if you have changed the 
  1353. current filename.
  1354.  
  1355. The [+cmd] can be used to position the cursor in the newly opened file:
  1356.     +        Start at the last line.
  1357.     +{num}        Start at line {num}.
  1358.     +/{pat}        Start at first line containing {pat}. {pat} must not
  1359.             contain any spaces.
  1360.     +{command}    Execute {command} after opening the new file.
  1361.             {command} is an Ex command. It must not contain 
  1362.             spaces.
  1363.  
  1364. When reading a file when the 'textmode' option is off (default for
  1365. non-MSDOS) the <LF> character is interpreted as end-of-line. If 'textmode'
  1366. is on (default for MSDOS), <CR><LF> is also interpreted as end-of-line.
  1367.  
  1368. When writing a file when the 'textmode' option is off a <LF> character is
  1369. used to separate lines. When the 'textmode' option is on <CR><LF> is used.
  1370.  
  1371. You can read a file with 'textmode' set and write it with 'textmode' reset.
  1372. This will replace all <CR><LF> pairs by <LF>. If you read a file with
  1373. 'textmode' reset and write with 'textmode' set, all <LF> characters will be
  1374. replaced by <CR><LF>.
  1375.  
  1376. If you start editing a new file and the 'textauto' option is set, Vim will
  1377. try to detect whether the lines in the file are separated by a single <LF>
  1378. (as used on Unix and Amiga) or by a <CR><LF> pair (MSDOS). It reads up to
  1379. the first <LF> and checks if there is a <CR> in front of it. If there is the
  1380. 'textmode' option is set, otherwise it is reset. If the 'textmode' option is
  1381. set on non-MSDOS systems the message "[textmode]" is shown to remind you
  1382. that something unusual is happening. On MSDOS systems you get the message
  1383. "[notextmode]" if the 'textmode' option is not set.
  1384.  
  1385. Before editing binary, executable or Vim script files you should set the
  1386. 'textmode' and 'textauto' options off. With 'textmode' on you risk that
  1387. single <LF> characters are unexpectedly replaced with <CR><LF>. A simple way
  1388. to do this is by starting Vim with the "-b" option.
  1389.  
  1390.  
  1391. 5.3 The argument list
  1392.  
  1393. If you give more than one filename when starting Vim, this list is
  1394. remembered as the argument list. Do not confuse this with the file list,
  1395. which you can see with the ":files" command. The argument list was already
  1396. present in vi, the file list is new in Vim. The file names in the argument
  1397. list will also be present in the file list (unless they were deleted with
  1398. ":bdel").
  1399.  
  1400. You can use the argument list with the following commands:
  1401.  
  1402. :ar[gs]            Print the argument list, with the current file in
  1403.             square brackets.
  1404.  
  1405. :[count]argu[ment] [count] [+cmd]
  1406.             Edit file [count] in the argument list, unless
  1407.             changes have been made and the 'autowrite' option is
  1408.             off. {Vi: no such command}
  1409.  
  1410. :[count]argu[ment]! [count] [+cmd]
  1411.             Edit file [count] in the argument list, discard any
  1412.             changes to the current buffer. {Vi: no such command}
  1413.  
  1414. :[count]n[ext] [+cmd]    Edit [count] next file, unless changes have been 
  1415.             made and the 'autowrite' option is off {Vi: no 
  1416.             count}.
  1417.  
  1418. :[count]n[ext]! [+cmd]    Edit [count] next file, discard any changes to the 
  1419.             buffer {Vi: no count}.
  1420.  
  1421. :ar[gs] [+cmd] {filelist}
  1422. :n[ext] [+cmd] {filelist}
  1423.             Define {filelist} as the new argument list and edit
  1424.             the first one, unless changes have been made and the
  1425.             'autowrite' option is off.
  1426.  
  1427. :ar[gs]! [+cmd] {filelist}
  1428. :n[ext]! [+cmd] {filelist}
  1429.             Define {filelist} as the new argument list and edit
  1430.             the first one. Discard any changes to the buffer.
  1431.  
  1432. :[count]N[ext] [count] [+cmd]
  1433.             Edit [count] previous file in argument list, unless 
  1434.             changes have been made and the 'autowrite' option is 
  1435.             off {Vi: no count}.
  1436.  
  1437. :[count]N[ext]! [count] [+cmd]
  1438.             Edit [count] previous file in argument list. Discard
  1439.             any changes to the buffer {Vi: no count}.
  1440.  
  1441. :[count]pre[vious] [count] [+cmd]
  1442.             Same as :Next {Vi: only in some versions}
  1443.  
  1444. :rew[ind] [+cmd]    Start editing the first file in the argument list,
  1445.             unless changes have been made and the 'autowrite'
  1446.             option is off.
  1447.  
  1448. :rew[ind]! [+cmd]    Start editing the first file in the argument list.
  1449.             Discard any changes to the buffer.
  1450.  
  1451. :la[st] [+cmd]        Start editing the last file in the argument list, unless
  1452.             changes have been made and the 'autowrite' option is
  1453.             off. {not in Vi}
  1454.  
  1455. :la[st]! [+cmd]        Start editing the last file in the argument list.
  1456.             Discard any changes to the buffer. {not in Vi}
  1457.  
  1458. :[count]wn[ext] [+cmd]    Write current file and start editing the [count] 
  1459.             next file. {not in Vi}
  1460.  
  1461. :[count]wn[ext] [+cmd] {file}
  1462.             Write current file to {file} and start editing the
  1463.             [count] next file, unless {file} already exists and
  1464.             the 'writeany' option is off. {not in Vi}
  1465.  
  1466. :[count]wn[ext]! [+cmd] {file}
  1467.             Write current file to {file} and start editing the
  1468.             [count] next file. {not in Vi}
  1469.  
  1470. :[count]wN[ext][!] [+cmd] [file]
  1471. :[count]wp[revous][!] [+cmd] [file]
  1472.             Same as :wnext, but go to previous file instead of
  1473.             next. {not in Vi}
  1474.  
  1475. The [count] in the commands above defaults to one. For some commands it is
  1476. possible to use two counts. The last one (rightmost one) is used.
  1477.  
  1478. For [+cmd] see 5.2.
  1479.  
  1480. The wildcards in the argument list are expanded and the filenames are sorted.
  1481. Thus you can use the command "vim *.c" to edit all the C files. From within 
  1482. Vim the command ":n *.c" does the same.
  1483.  
  1484. You are protected from leaving Vim if you are not editing the last file in 
  1485. the argument list. This prevents you from forgetting that you were editing one 
  1486. out of several files. To exit anyway try to exit twice. If there are changes
  1487. in the current buffer this will fail. You can exit anyway, and save any
  1488. changes, with the ":wq!" command. To lose any changes use the ":q!" command.
  1489.  
  1490.  
  1491. 5.4 Writing and quitting
  1492.  
  1493. :[range]w[rite][!]    Write the specified lines to the current file.
  1494.  
  1495. :[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  1496.             already exists and the 'writeany' option is off.
  1497.  
  1498. :[range]w[rite]! {file}    Write the specified lines to {file}. Overwrite an
  1499.             existing file.
  1500.  
  1501. :[range]w[rite][!] >>    Append the specified lines to the current file.
  1502.  
  1503. :[range]w[rite][!] >> {file}
  1504.             Append the specified lines to {file}. <!> forces the
  1505.             write even if file does not exist.
  1506.  
  1507. :[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  1508.             (note the space in front of the <!>).
  1509.  
  1510. The default [range] for the ":w" command is the whole buffer (1,$).
  1511. If a file name is give with ":w" it becomes the alternate file. This can be
  1512. used when the write fails and you want to try again later with ":w #".
  1513.  
  1514.  
  1515. :q[uit]         Quit, unless changes have been made or not editing 
  1516.             the last file in the argument list.
  1517.  
  1518. :q[uit]!        Quit always, without writing.
  1519.  
  1520. :cq            Quit always, without writing, and return an error 
  1521.             code. Used for Manx's QuickFix mode (see 5.5).
  1522.  
  1523. :wq            Write the current file. Exit if not editing the
  1524.             last file in the argument list.
  1525.  
  1526. :wq!            Write the current file and exit.
  1527.  
  1528. :wq {file}        Write to {file}. Exit if not editing the last
  1529.             file in the argument list.
  1530.  
  1531. :wq! {file}        Write to {file} and exit.
  1532.  
  1533. :x[it][!] [file]    Like ":wq", but write only when changes have been
  1534.             made.
  1535.  
  1536. :exi[t][!] [file]    Same as :xit.
  1537.  
  1538. ZZ            Write current file, if modified, and exit (same as
  1539.             ":x").
  1540.  
  1541. If you write to an existing file (but do not append) while the 'backup' or 
  1542. 'writebackup' option is on, a backup of the original file is made. On Unix 
  1543. systems the file is copied, on other systems the file is renamed. After the 
  1544. file has been successfully written and when the 'writebackup' option is on 
  1545. and the 'backup' option is off, the backup file is deleted.
  1546.  
  1547. 'backup'    'writebackup'        action
  1548.    off             off        no backup made
  1549.    off             on            backup made, deleted afterwards
  1550.    on             off        backup made, not deleted
  1551.    on             on            backup made, not deleted (default)
  1552.  
  1553. On Unix systems:
  1554. When you write to an existing file, that file is truncated and then filled 
  1555. with the new text. This means that protection bits, owner and symbolic links 
  1556. are unmodified. The backup file however, is a new file, owned by the user 
  1557. who edited the file. If it is not possible to create the backup file in the 
  1558. same directory as the original file, the directory given with the 
  1559. 'backupdir' option is used (default: home directory).
  1560.  
  1561. If the creation of a backup file fails, the write is not done. If you want 
  1562. to write anyway add a <!> to the command.
  1563.  
  1564. If the 'textmode' option is set <CR><LF> is used for end-of-line. This is
  1565. default for MSDOS. On other systems the message "[textmode]" is shown to
  1566. remind you that an usual end-of-line marker was used. If the 'textmode' is
  1567. not set LF is used for end-of-line. On MSDOS the message "[notextmode]" is
  1568. shown. See also the 'textmode' and 'textauto' options.
  1569.  
  1570.  
  1571. 5.5 Using the QuickFix mode
  1572.  
  1573. Vim has a special mode to speedup the edit-compile-edit cycle. This is
  1574. inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
  1575. The idea is to save the error messages from the compiler in a file and use
  1576. Vim to jump to the errors one by one. You can then examine each problem and
  1577. fix it, without having to remember all the error messages.
  1578.  
  1579. If you are using Manx's Aztec C compiler on the Amiga you should do the
  1580. following:
  1581. - Set the CCEDIT environment variable with the command
  1582.     mset "CCEDIT=vim -e"
  1583. - Compile with the -qf option. If the compiler finds any errors, Vim is 
  1584.   started and the cursor is positioned on the first error. The error message
  1585.   will be displayed on the last line. You can go to other errors with the
  1586.   commands mentioned below. You can fix the errors and write the file(s).
  1587. - If you exit Vim normally the compiler will re-compile the same file. If you
  1588.   exit with the :cq command, the compiler will terminate. Do this if you
  1589.   cannot fix the error, or if another file needs to be compiled first.
  1590.  
  1591. If you are using another compiler you should save the error messages in a
  1592. file and start Vim with "vim -e filename". An easy way to do this is with
  1593. the ":make" command (see below). The 'errorformat' option should be set to
  1594. match the error messages from your compiler (see below).
  1595.  
  1596. The following commands can be used if you are in QuickFix mode:
  1597.  
  1598. :cc [nr]        Display error [nr]. If [nr] is omitted, the same
  1599.             error is displayed again. {not in Vi}
  1600.  
  1601. :[count]cn        Display the [count] next error in the list that
  1602.             includes a file name. If there are no file names at
  1603.             all, go the the [count] next error. {not in Vi}
  1604.  
  1605. :[count]cp        Display the [count] previous error in the list that
  1606.             includes a file name. If there are no file names at
  1607.             all, go the the [count] previous error. {not in Vi}
  1608.  
  1609. :cq            Quit Vim with an error code, so that the compiler
  1610.             will not compile the same file again. {not in Vi}
  1611.  
  1612. :cf [errorfile]        Read the error file and jump to the first error.
  1613.             This is done automatically when Vim is started with
  1614.             the -e option. You can use this command when you
  1615.             keep Vim running while compiling. If you give the
  1616.             name of the errorfile, the 'errorfile' option will
  1617.             be set to [errorfile] {not in Vi}
  1618.  
  1619. :cl            List all errors. {not in Vi}
  1620.  
  1621. :make [arguments]    1. If the 'autowrite' option is set and the buffer
  1622.                was changed, write it.
  1623.             2. Any existing 'errorfile' is deleted.
  1624.             3. The program given with the 'makeprg' option is
  1625.                started (default "make") with the optional
  1626.                [arguments] and the output is saved in
  1627.                'errorfile' (for Unix it is also echoed on the
  1628.                screen).
  1629.             4. The 'errorfile' is then read and the first error
  1630.                is jumped to.
  1631.             5. The 'errorfile' is deleted.
  1632.             {not in Vi}
  1633.  
  1634. The name of the file can be set with the 'errorfile' option. The default is 
  1635. "AztecC.Err" for the Amiga and "errors" for other systems. The format of the
  1636. file from the Aztec compiler is:
  1637.  
  1638.     filename>linenumber:columnnumber:errortype:errornumber:errormessage
  1639.  
  1640.     filename    name of the file in which the error was detected
  1641.     linenumber    line number where the error was detected
  1642.     columnnumber    column number where the error was detected
  1643.     errortype    type of the error, normally a single <E> or <W>
  1644.     errornumber    number of the error (for lookup in the manual)
  1645.     errormessage    description of the error
  1646.  
  1647. Another compiler is likely to use a different format. You should set the
  1648. 'errorformat' option to a scanf-like string that describes the format. First
  1649. you need to know how scanf works. Look in the documentation of your C
  1650. compiler. Vim will understand eight conversion characters. Others are invalid.
  1651.     %f        file name (finds a string)
  1652.     %l        line number (finds a number)
  1653.     %c        column number (finds a number)
  1654.     %t        error type (finds a single character)
  1655.     %n        error number (finds a number)
  1656.     %m        error message (finds a string)
  1657.     %*<conv>    any scanf non-assignable conversion
  1658.     %%        the single <%> character
  1659.  
  1660. Examples:
  1661. "%f>%l:%c:%t:%n:%m"            for the AztecC.Err file
  1662. "%f:%l:\ %t%*[^0123456789]%n:\ %m"    for Aztec C error messages
  1663. "%f\ %l\ %t%*[^0123456789]%n:\ %m"    for SAS C
  1664. "\"%f\",%*[^0123456789]%l:\ %m"        default for generic C compilers
  1665. "%f:%l:%m"                for GCC
  1666.  
  1667. Note the backslash in front of a space and double quote. It is required for
  1668. the :set command.
  1669.  
  1670. The "%f" and "%m" conversions have to detect the end of the string. They
  1671. should be followed by a character that cannot be in the string. Everything
  1672. up to that character is included in the string. Be careful: "%f%l" will
  1673. include everything up to the first <%> in the file name. If the "%f" or "%m"
  1674. is at the end, everything up to the end of the line is included.
  1675.  
  1676. If a line is detected that does not completely match the 'errorformat', the
  1677. whole line is put in the error message and the entry is marked "not valid"
  1678. These lines are skipped with the ":cn" and ":cp" commands (unless there is
  1679. no valid line at all). You can use ":cl" to display all the error messages.
  1680.  
  1681. If the error format does not contain a file name Vim cannot switch to the
  1682. correct file. You will have to do this by hand.
  1683.  
  1684. If you have a compiler that produces error messages that do not fit in the
  1685. format string, you could write a program that translates the error messages
  1686. into this format. You can use this program with the ":make" command by
  1687. changing the 'makeprg' option. For example:
  1688.     ":set mp=make\ \\\|&\ error_filter".
  1689. The backslashes before the pipe character are required to avoid it to be
  1690. recognized as a command separator. The backslash before each space is
  1691. required for the set command.
  1692.  
  1693. The ":make" command executes the command given with the 'makeprg' option.
  1694. This is done by passing the command to the shell given with the 'shell'
  1695. option. This works almost like typing
  1696.  
  1697.     ":!{makeprg} [arguments] {shellpipe} {errorfile}".
  1698.  
  1699. {makeprg} is the string given with the 'makeprg' option. Any command can be
  1700. used, not just "make". Characters <%> and <#> are expanded as usual on a
  1701. command line. You can use "#<" to insert the current filename without
  1702. extension, for example ":set makeprg=make\ #<.o".
  1703.  
  1704. [arguments] is anything that is typed after ":make".
  1705. {shellpipe} is the 'shellpipe' option.
  1706. {errorfile} is the 'errorfile' option.
  1707.  
  1708. The 'shellpipe' option defaults to ">" for the Amiga and MSDOS. This means
  1709. that the output of the compiler is saved in a file and not shown on the
  1710. screen directly. For Unix "| tee" is used. The compiler output is shown on
  1711. the screen and saved in a file the same time. Depending on the shell used
  1712. "|& tee" or "2>&1| tee" is the default, so stderr output will be included.
  1713.  
  1714. There are some restrictions to the Quickfix mode on the Amiga. The
  1715. compiler only writes the first 25 errors to the errorfile (Manx's
  1716. documentation does not say how to get more). If you want to find the others,
  1717. you will have to fix a few errors and exit the editor. After recompiling,
  1718. up to 25 remaining errors will be found.
  1719.  
  1720. On the Amiga, if Vim was started from the compiler, the :sh and :! commands
  1721. will not work, because Vim is then running in the same process as the
  1722. compiler and these two commands may guru the machine then.
  1723.  
  1724. If you insert or delete lines, mostly the correct error location is still 
  1725. found because hidden marks are used (Manx's Z editor does not do this). 
  1726. Sometimes, when the mark has been deleted for some reason, the message "line 
  1727. changed" is shown to warn you that the error location may not be correct. If 
  1728. you quit Vim and start again the marks are lost and the error locations may
  1729. not be correct anymore.
  1730.  
  1731.  
  1732. 5.6 Editing binary files
  1733.  
  1734. Although Vim was made to edit text files, it is possible to edit binary
  1735. files. The "-b" command line option (b for binary) sets some options for
  1736. editing binary files ('binary' on, 'textwidth' to 0, 'textmode' and
  1737. 'textauto' off, 'modelines' to 0, 'expandtab' off). Setting the 'binary'
  1738. option has the same effect. Don't forget to do this before reading the file.
  1739.  
  1740. There are a few things to remember when editing binary files:
  1741. - When editing executable files the number of characters must not change.
  1742.   Use only the "R" or "r" command to change text. Do not delete characters
  1743.   with "x" or by backspacing.
  1744. - Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
  1745.   split in two.
  1746. - When there are not many end-of-line characters, the lines will become very
  1747.   long. If you want to edit a line that does not fit on the screen reset the
  1748.   'wrap' option. Horizontal scrolling is used then. If a line becomes too
  1749.   long (more than about 32767 characters on the Amiga, much more on 32-bit
  1750.   systems) you cannot edit that line. The line will be split when reading
  1751.   the file. It is also possible that you get an "out of memory" error when
  1752.   reading the file.
  1753. - Make sure the 'textmode' and 'textauto' options are off before loading the
  1754.   file. In 'textmode' both <CR><LF> and <LF> are considered to end a line
  1755.   and when the file is written the <LF> will be replaced by <CR><LF>. The
  1756.   'modelines' option should also be off, because there may be a string like
  1757.   ":vi:" in the file that would give unpredictable results.
  1758. - <NUL> characters are shown on the screen as ^@. You can enter them with
  1759.   "CTRL-V CTRL-@" or "CTRL-V 000" {vi cannot handle <NUL> characters in the
  1760.   file}
  1761. - To insert a <LF> character in the file split up a line. When writing the
  1762.   buffer to a file a <LF> will be written for the end of line.
  1763. - Vim normally appends an end-of-line character at the end of the file if
  1764.   there is none. Setting the 'binary' option prevents this. If you want to
  1765.   add the final end-of-line, set the 'endofline' option. You can also read the
  1766.   value of this option to see if there was an end-of-line character for the
  1767.   last line (you cannot see this in the text).
  1768.  
  1769.  
  1770.     6. Cursor motions
  1771.  
  1772. These commands move the cursor position. If the new position is off of the
  1773. screen, the screen is scrolled to show the cursor (see also 'scrolljump' 
  1774. option).
  1775.  
  1776. The motion commands can be used after other commands, called operators, to
  1777. have the command operate on the text that was moved over. That is the text
  1778. between the cursor position before and after the motion. If the motion
  1779. includes a count and the operator also had a count, the two counts are
  1780. multiplied. For example: "2d3w" deletes six words.
  1781.     The operator either affects whole lines, or the characters between 
  1782. the start and end position. Generally, motions that move between lines
  1783. affect lines (are linewise), and motions that move within a line affect
  1784. characters. However, there are some exceptions.
  1785.     A character motion is either inclusive or exclusive. When inclusive,
  1786. the start and end position of the motion are included in the operation.
  1787. When exclusive, the last character towards the end of the buffer is not
  1788. included. Linewise motions always include the start and end position.
  1789.     Which motions are linewise, inclusive or exclusive is mentioned 
  1790. below. There are however, two general exceptions:
  1791. 1. If the motion is exclusive and the end of the motion is in column 1, the 
  1792.    end of the motion is moved to the end of the previous line and the motion 
  1793.    becomes inclusive. Example: "}" ends at the first line after a paragraph, 
  1794.    but "V}" will not include that line.
  1795. 2. If the motion is exclusive, the end of the motion is in column 1 and the 
  1796.    start of the motion was at or before the first non-blank in the line, the 
  1797.    motion becomes linewise. Example: If a paragraph begins with some blanks 
  1798.    and you do "d}" while standing on the first non-blank, all the lines of 
  1799.    the paragraph are deleted, including the blanks. If you do a put now, the 
  1800.    deleted lines will be inserted below the cursor position.
  1801.  
  1802. Instead of first giving the operator and then a motion you can use Visual
  1803. mode: mark the start of the text with <v>, move the cursor to the end of the
  1804. text that is to be affected and then hit the operator. The text between the
  1805. start and the cursor position is highlighted, so you can see what text will
  1806. be operated upon. This allows much more freedom, but requires more key
  1807. strokes and has limited redo functionality. See the chapter on Visual mode.
  1808.  
  1809. If you want to know where you are in the file use the "CTRL-G" command. If 
  1810. you set the 'ruler' option, the cursor position is continuously shown in the 
  1811. status line (which slows down Vim a little).
  1812.  
  1813. NOTE: Experienced users prefer the hjkl keys because they are always right
  1814. under their fingers. Beginners often prefer the arrow keys, because they
  1815. do not know what the hjkl keys do. The mnemonic value of hjkl is clear from
  1816. looking at the keyboard. Think of j as an arrow pointing downwards.
  1817.  
  1818. 6.1 Left-right motions
  1819.  
  1820. h        or
  1821. <C_LEFT>    or
  1822. CTRL-H        or
  1823. <BS>            [count] characters to the left (exclusive).
  1824.  
  1825. l        or
  1826. <C_RIGHT>    or
  1827. <SPACE>            [count] characters to the right (exclusive).
  1828.  
  1829. 0            To the first character of the line (exclusive).
  1830.  
  1831. ^            To the first non-blank character of the line
  1832.             (exclusive).
  1833.  
  1834. $            To the end of line [count] from the cursor
  1835.             (inclusive).
  1836.  
  1837. |            To column [count] (inclusive).
  1838.  
  1839. f<char>            To [count]'th occurrence of <char> to the right. The
  1840.             cursor is placed on <char> (inclusive).
  1841.  
  1842. F<char>            To the [count]'th occurrence of <char> to the left.
  1843.             The cursor is placed on <char> (inclusive).
  1844.  
  1845. t<char>            Till before [count]'th occurrence of <char> to the
  1846.             right. The cursor is placed on the character left of 
  1847.             <char> (inclusive).
  1848.  
  1849. T<char>            Till after [count]'th occurrence of <char> to the
  1850.             left. The cursor is placed on the character right of
  1851.             <char> (inclusive).
  1852.  
  1853. ;            Repeat latest f, t, F or T [count] times.
  1854.  
  1855. ,            Repeat latest f, t, F or T in opposite direction
  1856.             [count] times.
  1857.  
  1858. These commands move the cursor to the specified column in the current line.
  1859. They stop at the first column and at the end of the line, except "$", which 
  1860. may move to one of the next lines.
  1861.  
  1862.  
  1863. 6.2 Up-down motions
  1864.  
  1865. k        or
  1866. <C_UP>        or
  1867. CTRL-P            [count] lines upward (linewise).
  1868.  
  1869. j        or
  1870. <C_DOWN>    or
  1871. CTRL-J        or
  1872. <LF>        or
  1873. CTRL-N            [count] lines downward (linewise).
  1874.  
  1875. -  <minus>        [count] lines upward, on the first non-blank
  1876.             character (linewise).
  1877.  
  1878. +        or
  1879. CTRL-M        or
  1880. <CR>            [count] lines downward, on the first non-blank
  1881.             character (linewise).
  1882.  
  1883. _  <underscore>        [count] - 1 lines downward, on the first non-blank
  1884.             character (linewise).
  1885.  
  1886. G            Goto line [count], default last line, on the first
  1887.             non-blank character (linewise).
  1888.  
  1889. :[range]        Set the cursor on the (last) specified line number
  1890.             (cannot be used with an operator).
  1891.  
  1892. {count}%        Go to {count} percentage in the file, on the first
  1893.             non-blank in the line (linewise). To compute the new
  1894.             line number this formula is used: {count} *
  1895.             number-of-lines / 100. {not in Vi}
  1896.  
  1897. These commands move to the specified line. They stop when reaching the first 
  1898. or the last line. The first two commands put the cursor in the same column 
  1899. (if possible) as it was after the last command that changed the column, 
  1900. except after the "$" command, then the cursor will be put on the last 
  1901. character of the line.
  1902.  
  1903.  
  1904. 6.3 Word motions
  1905.  
  1906. <SC_RIGHT>    or
  1907. w            [count] words forward (exclusive).
  1908.  
  1909. W            [count] WORDS forward (exclusive).
  1910.  
  1911. e            Forward to the end of word [count] (inclusive).
  1912.  
  1913. E            Forward to the end of WORD [count] (inclusive).
  1914.  
  1915. <SC_LEFT>    or
  1916. b            [count] words backward (exclusive).
  1917.  
  1918. B            [count] WORDS backward (exclusive).
  1919.  
  1920. These commands move over words or WORDS. A word consists of a sequence of 
  1921. letters, digits and underscores, or a sequence of other non-blank 
  1922. characters, separated with white space (spaces, tabs, end of line). A WORD
  1923. consists of a sequence of non-blank characters, separated with white space.
  1924. An empty line is also considered to be a word and a WORD.
  1925.  
  1926. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  1927. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  1928. word does not include the following white space. {Vi: "cw" when on a blank 
  1929. followed by other blanks changes only the first blank; this is probably a 
  1930. bug, because "dw" deletes all the blanks}
  1931.  
  1932. Another special case: When using the "w" motion in combination with an 
  1933. operator and the last word moved over is at the end of a line, the end of 
  1934. that word becomes the end of the operated text, not the first word in the 
  1935. next line.
  1936.  
  1937. The original vi implementation of "e" is buggy. For example, the "e" command 
  1938. will stop on the first character of a line if the previous line was empty. 
  1939. But when you use "2e" this does not happen. In Vim "ee" and "2e" are the 
  1940. same, which is more logical. However, this causes a small incompatibility 
  1941. between vi and Vim.
  1942.  
  1943.  
  1944. 6.4 Text object motions
  1945.  
  1946. (            [count] sentences backward (exclusive).
  1947.  
  1948. )            [count] sentences forward (exclusive).
  1949.  
  1950. {            [count] paragraphs backward (exclusive).
  1951.  
  1952. }            [count] paragraphs forward (exclusive).
  1953.  
  1954. ]]            [count] sections forward or to the next <{> in the
  1955.             first column. When used after an operator, then the
  1956.             <}> in the first column. (linewise).
  1957.  
  1958. ][            [count] sections forward or to the next <}> in the
  1959.             first column (linewise).
  1960.  
  1961. [[            [count] sections backward or to the previous <{> in
  1962.             the first column (linewise).
  1963.  
  1964. []            [count] sections backward or to the previous <}> in
  1965.             the first column (linewise).
  1966.  
  1967. These commands move over three kinds of text objects.
  1968.  
  1969. A sentence is defined as ending at a <.>, <!> or <?> followed by either the 
  1970. end of a line, or by a space. {Vi: two spaces} Any number of closing <)>, 
  1971. <]>, <"> and <'> characters my appear after the <.>, <!> or <?> before the 
  1972. spaces or end of line. A paragraph and section boundary is also a sentence 
  1973. boundary.
  1974.  
  1975. A paragraph begins after each empty line, and also at each of a set of 
  1976. paragraph macros, specified by the pairs of characters in the 'paragraphs' 
  1977. option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the 
  1978. macros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the 
  1979. first column). A section boundary is also a paragraph boundary. Note that
  1980. this does not include a <{> or <}> in the first column.
  1981.  
  1982. A section begins after a form-feed in the first column and at each of a set
  1983. of section macros, specified by the pairs of characters in the 'sections'
  1984. option. The default is "SHNHH HUnhsh".
  1985.  
  1986. The "]" and "[" commands stop at the <{> or <}" in the first column. This is
  1987. useful to find the start or end of a function in a C program. Note that the
  1988. first character of the command determines the search direction and the
  1989. second character the type of brace found.
  1990.  
  1991.  
  1992. 6.5 Pattern searches
  1993.  
  1994. /{pattern}[/]        Search forward for the [count]'th occurrence of
  1995.             {pattern} (exclusive).
  1996.  
  1997. /{pattern}/{offset}    Search forward for the [count]'th occurrence of
  1998.             {pattern} and go {offset} lines up or down (see 
  1999.             below). (linewise).
  2000.  
  2001. /            Search forward for the [count]'th latest used
  2002.             pattern with latest used {offset}.
  2003.  
  2004. //{offset}        Search forward for the [count]'th latest used
  2005.             pattern with new {offset}. If {offset} is empty no
  2006.             offset is used.
  2007.  
  2008. *            Search forward for the [count]'th occurrence of the
  2009.             ident after or under the cursor (exclusive). Only
  2010.             whole words are search for, like with the command
  2011.             "/\<indent\>". If there is no identifier after or
  2012.             under the cursor, any non-blank word is used to
  2013.             search for. {not in Vi}
  2014.  
  2015. #            Same as "*", but search backward. {not in Vi}
  2016.  
  2017. ?{pattern}[?]        Search backward for the [count]'th previous
  2018.             occurrence of {pattern} (exclusive).
  2019.  
  2020. ?{pattern}?{offset}    Search backward for the [count]'th previous
  2021.             occurrence of {pattern} and go {offset} lines up or
  2022.             down (see below) (linewise).
  2023.  
  2024. ?            Search backward for the [count]'th latest used
  2025.             pattern with latest used {offset}.
  2026.  
  2027. ??{offset}        Search backward for the [count]'th latest used
  2028.             pattern with new {offset}. If {offset} is empty no
  2029.             offset is used.
  2030.  
  2031. n            Repeat the latest "/" or "?" [count] times. {Vi: no
  2032.             count}
  2033.  
  2034. N            Repeat the latest "/" or "?" [count] times in
  2035.             opposite direction. {Vi: no count}
  2036.  
  2037. CTRL-C            Interrupt current (search) command.
  2038.  
  2039. These commands search for the specified pattern. With "/" and "?" an 
  2040. additional offset may be given. There are two types of offsets: line offsets 
  2041. and character offsets. {the character offsets are not in Vi}
  2042.  
  2043. The offset gives the cursor position relative to the found match:
  2044.     [num]    [num] lines downwards, in column 1
  2045.     +[num]    [num] lines downwards, in column 1
  2046.     -[num]    [num] lines upwards, in column 1
  2047.     e[+num]    [num] characters to the right of the end of the match
  2048.     e[-num]    [num] characters to the left of the end of the match
  2049.     s[+num]    [num] characters to the right of the start of the match
  2050.     s[-num]    [num] characters to the left of the start of the match
  2051.     b[+num]    [num] characters to the right of the start (begin) of the match
  2052.     b[-num]    [num] characters to the left of the start (begin) of the match
  2053.  
  2054. If a <-> or <+> is given but [num] is omitted, a count of one will be used.
  2055. When including an offset with 'e', the search becomes inclusive (the
  2056. character the cursor lands on is included in operations).
  2057.  
  2058. Examples:
  2059.  
  2060. pattern            cursor position
  2061. /test/+1        one line below "test", in column 1
  2062. /test/e            on the last t of "test"
  2063. /test/s+2        on the <s> of "test"
  2064. /test/b-3        three characters before "test"
  2065.  
  2066. If one of these commands is used after an operator, the characters between 
  2067. the cursor position before and after the search is affected. However, if a 
  2068. line offset is given, the whole lines between the two cursor positions are 
  2069. affected.
  2070.  
  2071. The last used <pattern> and <offset> are remembered. They can be used to
  2072. repeat the search, possibly in another direction or with another count. Note
  2073. that two patterns are remembered: one for 'normal' search commands and one
  2074. for the substitute command ":s". Each time an empty <pattern> is given, the
  2075. previously used <pattern> is used.
  2076.  
  2077. {In vi the :tag command sets a new search pattern when the tag is searched
  2078. for. In Vim this is not done, the previous search pattern is still
  2079. remembered}.
  2080.  
  2081. If the 'wrapscan' option is set (which is the default), searches wrap around 
  2082. the end of the buffer. If 'wrapscan' is not set, the backward search stops 
  2083. at the beginning and the forward search stops at the end of the buffer. If 
  2084. 'wrapscan' is set and the pattern was not found the error message "pattern
  2085. not found" is given, and the cursor will not be moved. If 'wrapscan' is not
  2086. set the message becomes "search hit BOTTOM without match" when searching
  2087. forward, or "search hit TOP without match" when searching backward. If
  2088. wrapscan is set and the search wraps around the end of the file the message
  2089. "search hit TOP, continuing at BOTTOM" or "search hit BOTTOM, continuing at
  2090. TOP" is given when searching backwards or forwards respectively.
  2091.  
  2092. The "*" and "#" commands search for the identifier currently under the
  2093. cursor. If there is no identifier under the cursor, the first one to the
  2094. right is used. This identifier may only contain letters, digits and
  2095. underscores. Note that if you type with ten fingers, the characters are easy
  2096. to remember: the "#" is under your left hand middle finger (search to the
  2097. left and up) and the "*" is under your right hand middle finger (search to
  2098. the right and down). If there is no identifier under or after the cursor, a
  2099. search is done for any word under or after the cursor. Blanks (<TAB>s and/or
  2100. <SPACE>s) are recognized as delimiters for this word.
  2101.  
  2102.  
  2103. The definition of a pattern:
  2104.  
  2105. Patterns may contain special characters, depending on the setting of the
  2106. 'magic' option.
  2107.  
  2108. 1.  A pattern is one or more branches, separated by '\|'. It matches anything
  2109.     that matches one of the branches. Example: "foo\|bar" matches "foo" and
  2110.     "bar.
  2111.  
  2112. 2.  A branch is one or more pieces, concatenated. It matches a match for the
  2113.     first, followed by a match for the second, etc. Example: "foo[0-9]bar",
  2114.     first match "foo", then a digit and then "bar".
  2115.  
  2116. 3.  A piece is an atom, possibly followed by:
  2117.       'magic'    'nomagic'
  2118.       option    option
  2119.     *      \*        matches 0 or more of the preceding atom
  2120.     \+      \+        matches 1 or more of the preceding atom {not
  2121.                 in Vi}
  2122.     \=      \=        matches 0 or 1 of the preceding atom {not in
  2123.                 Vi}
  2124.     Examples:
  2125.        .*      .\*        match anything, also empty string
  2126.        .\+      .\+        match any non-empty string
  2127.        foo\=      foo\=        match "fo" and "foo"
  2128.  
  2129.  
  2130. 4.  An atom can be:
  2131.     - One of these five:
  2132.       magic    nomagic
  2133.     .      \.        matches any single character
  2134.     \<      \<        matches the beginning of a word
  2135.     \>      \>        matches the end of a word
  2136.     ^      ^        at beginning of pattern, matches start of
  2137.                 line
  2138.     $      $        at end of pattern or in front of '\|',
  2139.                 matches end of line
  2140.     - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
  2141.     - A single character, with no special meaning, matches itself
  2142.     - A backslash followed by a single character, with no special meaning,
  2143.       matches the single character.
  2144.     - A range. This is a sequence of characters enclosed in '[]' with the 
  2145.       'magic' option, or enclosed in '\[]' with the 'nomagic' option. It 
  2146.       normally matches any single character from the sequence. If the 
  2147.       sequence begins with <^>, it matches any single character NOT in the 
  2148.       sequence. If two characters in the sequence are separated by <->, this 
  2149.       is shorthand for the full list of ASCII characters between them (e.g. 
  2150.       '[0-9]' matches any decimal digit). To include a literal <]> in the 
  2151.       sequence, make it the first character (following a possible <^>). To 
  2152.       include a literal '\-', make it the first or last character.
  2153.  
  2154. If the 'ignorecase' option is set, the case of letters is ignored.
  2155.  
  2156. It is impossible to have a pattern that contains a line break.
  2157.  
  2158. Examples:
  2159. ^beep(            Probably the start of the C function "beep".
  2160.  
  2161. [a-zA-Z]$        Any alphabetic character at the end of a line.
  2162.  
  2163. \(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
  2164.             A C identifier (will stop in front of it).
  2165.  
  2166. \(\.$\|\. \)        A period followed by end-of-line or a space.
  2167.             Note that "\(\. \|\.$\)" does not do the same,
  2168.             because '$' is not end-of-line in front of '\)'.
  2169.             This was done to remain vi-compatible.
  2170.  
  2171. [.!?][])"']*\($\|[ ]\)    A search pattern that finds the end of a sentence,
  2172.             with almost the same definition as the <)> command.
  2173.  
  2174. Technical detail:
  2175. <NUL> characters in the file are stored as <LF> in memory. In the display
  2176. they are shown as "^@". The translation is done when reading and writing
  2177. files. To match a <NUL> with a search pattern you can just enter CTRL-@ or
  2178. "CTRL-V 000". This is probably just what you expect. Internally the
  2179. character is replaced by a <LF> in the search pattern. What is unusual is
  2180. that typing CTRL_V CTRL_J also inserts a <LF>, thus also searches for a
  2181. <NUL> in the file. {vi cannot handle <NUL> characters in the file at all}
  2182.  
  2183.  
  2184. 6.6 Various motions
  2185.  
  2186. m<a-zA-Z>        Set mark <a-zA-Z> at cursor position (does not move 
  2187.             the cursor, this is not a motion command).
  2188.  
  2189. :[range]mar[k] <a-zA-Z>    Set mark <a-zA-Z> at last line number in [range], 
  2190.             column 0. Default is cursor line.
  2191.  
  2192. :[range]k<a-zA-Z>    Same as :mark, but the space before the mark name can
  2193.             be omitted.
  2194.  
  2195. '<a-z>            To the first non-blank character on the line with
  2196.             mark <a-z> (linewise).
  2197.  
  2198. '<A-Z>            To the first non-blank character on the line with
  2199.             mark <A-Z> in the correct file (linewise when in 
  2200.             same file, not a motion command when in other file). 
  2201.             {not in Vi}
  2202.  
  2203. `<a-z>            To the mark <a-z> (exclusive).
  2204.  
  2205. `<A-Z>            To the mark <A-Z> in the correct file (exclusive 
  2206.             when in same file, not a motion command when in 
  2207.             other file). {not in Vi}
  2208.  
  2209. :marks            List the current marks (not a motion command). {not 
  2210.             in Vi}
  2211.  
  2212. A mark is not visible in any way. It is just a position in the file that is
  2213. remembered. Do not confuse marks with named registers, they are totally 
  2214. unrelated.
  2215.  
  2216. Lowercase marks are only remembered as long as the file remains loaded. If
  2217. you quit editing the file, change a character in a line or delete a line
  2218. that contains a mark, that mark is erased. Lowercase marks can be used
  2219. in combination with operators. For example: "d't" deletes the lines from the
  2220. cursor position to mark <t>. Hint: Use mark <t> for Top, <b> for Bottom,
  2221. etc..
  2222.  
  2223. Marks are restored when using undo and redo.
  2224.  
  2225. Marks are remembered as long as the file remains in the buffer list.
  2226.  
  2227. Uppercase marks include the file name. {Vi: no uppercase marks} You can use 
  2228. them to jump from file to file. You can only use an uppercase mark with 
  2229. an operator if the mark is in the current file. The line number of the mark
  2230. remains correct, even if you insert/delete lines or edit another file for a
  2231. moment.
  2232.  
  2233.  
  2234. '[            To the first non-blank character on the first line 
  2235.             of the previously operated text or start of the last 
  2236.             putted text. {not in Vi}
  2237.  
  2238. `[            To the first character of the previously operated 
  2239.             text or start of the last putted text. {not in Vi}
  2240.  
  2241. ']            To the first non-blank character on the last line of 
  2242.             the previously operated text or end of the last 
  2243.             putted text. {not in Vi}
  2244.  
  2245. `]            To the last character of the previously operated 
  2246.             text or end of the last putted text. {not in Vi}
  2247.  
  2248. After executing an operator the Cursor is put at the beginning of the text 
  2249. that was operated upon. After a put command ("p" or "P") the cursor is 
  2250. sometimes placed at the first inserted line and sometimes on the last 
  2251. inserted character. The four commands above put the cursor at either
  2252. end. Example: After yanking 10 lines you want to go to the last one of them: 
  2253. "10Y']". After inserting several lines with the "p" command you want to jump 
  2254. to the lowest inserted line: "p']".
  2255.  
  2256. Note: After deleting text, the start and end positions are the same, except 
  2257. when using blockwise Visual mode. These commands do not work when no
  2258. operator or put command has been used yet in the current file. The position
  2259. may be incorrect after inserting text and ".p.
  2260.  
  2261.  
  2262. ''            To the first non-blank character of the line where
  2263.             the cursor was before the latest jump (linewise).
  2264.  
  2265. ``            To the position before latest jump (exclusive).
  2266.  
  2267. A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n", 
  2268. "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
  2269. the commands that start editing a new file. If you make the cursor "jump"
  2270. with one of these commands, the position of the cursor before the jump is
  2271. remembered. You can return to that position with the "''" and "``" command,
  2272. unless the line containing that position was changed or deleted.
  2273.  
  2274. CTRL-O            Go to [count] Older cursor position in jump list
  2275.             (not a motion command). {not in Vi}
  2276.  
  2277. CTRL-I            Go to [count] newer cursor position in jump list
  2278.             (not a motion command). {not in Vi}
  2279.  
  2280. :jumps            Print the jump list (not a motion command). {not in 
  2281.             Vi} 
  2282.  
  2283. Jumps are remembered in a jump list. With the CTRL-O and CTRL-I command you 
  2284. can go to cursor positions before older jumps, and back again. Thus you can 
  2285. move up and down the list.
  2286.  
  2287. For example, after three jump commands you have this jump list:
  2288.  
  2289.  jump line  file
  2290.    1     1  -current-
  2291.    2    70  -current-
  2292.    3  1154  -current-
  2293. >
  2294.  
  2295. You are currently in line 1167. If you then use the CTRL-O command, the 
  2296. cursor is put in line 1154. This results in:
  2297.  
  2298.  jump line  file
  2299.    1     1  -current-
  2300.    2    70  -current-
  2301. >  3  1154  -current-
  2302.    4  1167  -current-
  2303.  
  2304. The pointer will be set at the last used jump position. The next CTRL-O 
  2305. command will use the entry above it, the next CTRL-I command will use the 
  2306. entry below it. If the pointer is below the last entry, this indicates that 
  2307. you did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command 
  2308. will cause the cursor position to be added to the jump list, so you can get 
  2309. back to the position before the CTRL-O. In this case this is line 1167.
  2310.  
  2311. With more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I 
  2312. you can go back to 1154 and 1167 again.
  2313.  
  2314. If you use a jump command, the current line number is inserted at the end of 
  2315. the jump list. If you used CTRL-O or CTRL-I just before that, the same line 
  2316. may be in the list twice. This may be a bit strange. Just try it and look at 
  2317. the jump list with the :jumps command. Note that this behaviour is different 
  2318. from the tag stack.
  2319.  
  2320. After the CTRL-O command that got you into line 1154 you could give another 
  2321. jump command (e.g. "G"). The jump list would then become:
  2322.  
  2323.  jump line  file
  2324.    1     1  -current-
  2325.    2    70  -current-
  2326.    3  1154  -current-
  2327.    4  1167  -current-
  2328.    5  1154  -current-
  2329. >
  2330.  
  2331. As long as you stay in the same file, the line numbers will be adjusted for 
  2332. deleted and inserted lines. If you go to another file the line numbers may 
  2333. be wrong (keeping them correct would take too much time). If you want to 
  2334. avoid this use a :jumps command before changing files. This will update the 
  2335. line numbers in the current file.
  2336.  
  2337. %            Find the next item in this line after or under the
  2338.             cursor and jump to its match (inclusive). Items can
  2339.             be:
  2340.             ([{}])        parenthesis or (curly/square) brackets
  2341.              /* */        start or end of C-style comment
  2342.             #if, #ifdef, #else, #elif, #endif
  2343.                     C preprocessor conditionals
  2344.             Parens and braces preceded with a backslash are
  2345.             ignored. Parens and braces inside quotes are ignored,
  2346.             unless the number of parens/braces in a line is uneven
  2347.             and this line and the previous one does not end in a
  2348.             backslash. No count is allowed ({count}% jumps to a
  2349.             line {count} percentage down the file).
  2350.             Using '%' on #if/#else/#endif makes the movement
  2351.             linewise.
  2352.  
  2353. [(            go to [count] previous unmatched <(>. {not in Vi}
  2354.  
  2355. [{            go to [count] previous unmatched <{>. {not in Vi}
  2356.  
  2357. ])            go to [count] next unmatched <)>. {not in Vi}
  2358.  
  2359. ]}            go to [count] next unmatched <}>. {not in Vi}
  2360.  
  2361. The above four commands can be used to go to the start or end of the current
  2362. code block. It is like doing "%" on the <(>, <)>, <{> or <}> at the other
  2363. end of the code block, but you can do this from anywhere in the code block.
  2364. Very useful for C programs. Example: When standing on "case x:", "[{" will
  2365. bring you back to the switch statement.
  2366.  
  2367. H            To line [count] from top (Home) of screen (default:
  2368.             first line on the screen) on the first non-blank 
  2369.             character (linewise).
  2370.  
  2371. M            To Middle line of screen, on the first non-blank
  2372.             character (linewise).
  2373.  
  2374. L            To line [count] from bottom of screen (default: Last
  2375.             line on the screen) on the first non-blank character 
  2376.             (linewise).
  2377.  
  2378.  
  2379.     7. Scrolling
  2380.  
  2381. Move edit window downwards (this means that more lines downwards in the text
  2382. buffer are seen):
  2383.  
  2384. CTRL-E            Window [count] lines downwards in the buffer
  2385.  
  2386. CTRL-D            Window Downwards in the buffer. The number of lines
  2387.             comes from the 'scroll' option (default: half a
  2388.             screen). If [count] given, first set 'scroll' option
  2389.             to [count].
  2390.  
  2391. <SC_DOWN>    or
  2392. CTRL-F            Window [count] pages Forwards (downwards) in the
  2393.             buffer.
  2394.  
  2395. Move edit window upwards (this means that more lines upwards in the text
  2396. buffer are seen): 
  2397.  
  2398. CTRL-Y            Window [count] lines upwards in the buffer.
  2399.  
  2400. CTRL-U            Window Upwards in the buffer. The number of lines
  2401.             comes from the 'scroll' option (default: half a
  2402.             screen). If [count] given, first set 'scroll' option
  2403.             to [count].
  2404.  
  2405. <SC_UP>        or
  2406. CTRL-B            Window [count] pages Backwards (upwards) in the
  2407.             buffer.
  2408.  
  2409. Window repositioning:
  2410.  
  2411. z<CR>            Redraw, line [count] at top of window (default
  2412.             cursor line). Put cursor at first non-blank in the
  2413.             line.
  2414.  
  2415. zt            Like "z<CR>", but leave the cursor in the same
  2416.             column. {not in Vi}
  2417.  
  2418. z{height}<CR>        Redraw, make window {height} lines tall. This is
  2419.             useful to make the number of lines small when screen
  2420.             updating is very slow. Cannot make the height more
  2421.             than the physical screen height.
  2422.  
  2423. z.            Redraw, line [count] at center of window (default 
  2424.             cursor line). Put cursor at first non-blank in the
  2425.             line.
  2426.  
  2427. zz            Like "z.", but leave the cursor in the same column.
  2428.             {not in Vi}
  2429.  
  2430. z-            Redraw, line [count] at bottom of window (default 
  2431.             cursor line). Put cursor at first non-blank in the
  2432.             line.
  2433.  
  2434. zb            Like "z-", but leave the cursor in the same column.
  2435.             {not in Vi}
  2436.  
  2437. These commands move the contents of the window. If the cursor position is 
  2438. moved off of the window, the cursor is moved onto the window. A page is the 
  2439. number of lines in the window minus two. The mnemonics for these commands 
  2440. may be a bit confusing. Remember that the commands refer to moving the 
  2441. window upwards or downwards in the buffer. But when the window moves upwards 
  2442. in the buffer, the text in the window moves downwards on your screen.
  2443.  
  2444.  
  2445.     8. Tags
  2446.  
  2447. :ta[g][!] {ident}    Jump to the definition of {ident}, using the
  2448.             information in the tags file. Put {ident} in the tag
  2449.             stack. See below for [!].
  2450.  
  2451. CTRL-]            ":ta" to the identifier under or after cursor. Put 
  2452.             the identifier in the tag stack. {Vi: identifier 
  2453.             after the cursor}
  2454.  
  2455. CTRL-T            Jump to [count] older entry in the tag stack
  2456.             (default 1). {not in Vi}
  2457.  
  2458. :[count]po[p][!]    Jump to [count] older entry in tag stack (default 1).
  2459.             See below for [!]. {not in Vi}
  2460.  
  2461. :[count]ta[g][!]    Jump to [count] newer entry in tag stack (default 1).
  2462.             See below for [!]. {not in Vi}
  2463.  
  2464. :tags            Show the contents of the tag stack. The active
  2465.             entry is marked with a <>>. {not in Vi}
  2466.  
  2467. A tag is an identifier that appears in the "tags" file. It is a sort of label
  2468. that can be jumped to. For example: In C programs each function name can be 
  2469. used as a tag.
  2470.  
  2471. With the ":tag" command the cursor will be positioned on the tag. With the
  2472. CTRL-] command, the identifier on which the cursor is standing is used as the
  2473. tag. If the cursor is not on an identifier, the first identifier rightwards 
  2474. of the cursor is used.
  2475.  
  2476. The 'ignorecase' option can be used to make the tag search case insensitive.
  2477.  
  2478. If the tag is in the current file this will always work. Otherwise the
  2479. performed actions depend on whether the current file was changed, whether a !
  2480. is added to the command and on the 'autowrite' option:
  2481.  
  2482.   tag in       file        autowrite
  2483. current file  changed   !   option      action
  2484. -----------------------------------------------------------------------------
  2485.     yes         x    x     x      goto tag
  2486.     no         no    x     x      read other file, goto tag
  2487.     no        yes    yes    x   abandon current file, read other file, goto
  2488.                       tag
  2489.     no        yes    no    on  write current file, read other file, goto
  2490.                       tag
  2491.     no        yes    no   off  fail
  2492. -----------------------------------------------------------------------------
  2493.  
  2494. - If the tag is in the current file, the command will always work.
  2495. - If the tag is in another file and the current file was not changed, the 
  2496.   other file will be made the current file and read into the buffer.
  2497. - If the tag is in another file, the current file was changed and a ! is 
  2498.   added to the command, the changes to the current file are lost, the other 
  2499.   file will be made the current file and read into the buffer.
  2500. - If the tag is in another file, the current file was changed and the 
  2501.   'autowrite' option is set, the current file will be written, the other 
  2502.   file will be made the current file and read into the buffer.
  2503. - If the tag is in another file, the current file was changed and the 
  2504.   'autowrite' option is not set, the command will fail. If you want to save 
  2505.   the changes, use the ":w" command and then use ":tag" without an argument. 
  2506.   This works because the tag is put on the stack anyway. If you want to lose 
  2507.   the changes you can use the ":tag!" command.
  2508.  
  2509. The ":tag" command works very well for C programs. If you see a call to a
  2510. function and wonder what that function does, position the cursor inside of 
  2511. the function name and hit CTRL-]. This will bring you to the function 
  2512. definition. An easy way back is with the CTRL-T command. Also read about the 
  2513. tag stack below.
  2514.  
  2515. A tags file can be created with the external command 'ctags'. It will 
  2516. contain a tag for each function. Some versions of 'ctags' will also make a 
  2517. tag for each "#defined" macro.
  2518.  
  2519. The lines in the tags file should have this format:
  2520.  
  2521.     {tag}{separator}{filename}{separator}{command}
  2522.  
  2523. {tag}        the identifier
  2524. {separator}    one or more <TAB> or space characters
  2525. {filename}    the file that contains the definition of {tag}
  2526. {command}    the Ex command that positions the cursor on the tag.
  2527.  
  2528. The command can be any Ex command, but normally it is a search command like 
  2529. "/^main(argc, argv)". If it is a search command, and the search fails,
  2530. another try is done to search for "^main(" (the tag with <^> prepended and
  2531. <)> appended). When using function names, this will find the function name
  2532. when it is in column 0. This will help when the arguments to the function
  2533. have changed since the tags file was made. If this search also fails another
  2534. try is done with "^[#a-zA-Z_].*main(". This means: A line starting with <#>
  2535. or an identifier and containing the tag followed by <(>. This will find
  2536. macro names and function names with a type prepended. {the two extra
  2537. searches are not in vi}.
  2538.  
  2539. {In vi the :tag command sets a new search pattern when the tag is searched
  2540. for. In Vim this is not done, the previous search pattern is still
  2541. remembered. The search pattern for the tag is not remembered.}.
  2542.  
  2543.  
  2544. The 'tags' option is a list of file names separated by spaces. Each of these 
  2545. files is searched for the tag. This can be used to use a different file than 
  2546. the default file "tags". It can also be used to access a common tags file. 
  2547. For example:
  2548.  
  2549. :set tags=tags\ /home/user/commontags
  2550.  
  2551. The tag will first be searched for in the file "tags" in the current
  2552. directory. If it is not found there the file "/home/user/commontags" will be
  2553. searched for the tag. The backslash is required for the space to be included
  2554. in the string option.
  2555.  
  2556. If the 'tagrelative' option is set (which is the default) and using a tag file
  2557. in another directory, file names in that tag file are relative to the
  2558. directory where the tag file is.
  2559.  
  2560.  
  2561. The tags that you use are remembered in the tag stack. You can print this 
  2562. stack with the ":tags" command. The result looks like this:
  2563.  
  2564.   # TO tag      FROM line in file
  2565.   1 main               1  harddisk2:text/vim/test
  2566. > 2 FuncA             58  -current-
  2567.   3 FuncC            357  harddisk2:text/vim/src/amiga.c
  2568.  
  2569. This list shows the tags that you jumped to and the cursor position before that 
  2570. jump. The older tags are at the top, the newer at the bottom.
  2571.  
  2572. The <>> points to the active entry. This is the tag that will be used by the 
  2573. next ":tag" command. The CTRL-T and ":pop" command will use the position 
  2574. above the active entry.
  2575.  
  2576. The line number and file name are remembered to be able to get back to where 
  2577. you were before the tag command. The line number will be correct, also when
  2578. deleting/inserting lines, unless this was done by another program (e.g.
  2579. another instance of Vim).
  2580.  
  2581. You can jump to previously used tags with several commands. Some examples:
  2582.  
  2583.     ":pop" or CTRL-T     to position before previous tag
  2584.     {count}CTRL_T        to position before {count} older tag
  2585.     ":tag"            to newer tag
  2586.     ":0tag"         to last used tag
  2587.  
  2588. The most obvious way to use this is while browsing through the call graph of 
  2589. a program. Consider the following call graph:
  2590.  
  2591.     main  --->  FuncA  --->  FuncC
  2592.           --->  FuncB
  2593.  
  2594. (Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
  2595. You can get from main to FuncA by using CTRL-] on the call to FuncA. Then 
  2596. you can CTRL-] to get to FuncC. If you now want to go back to main you can 
  2597. use CTRL-T twice. Then you can CTRL-] to FuncB.
  2598.  
  2599. If you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the
  2600. current position in the stack. If the stack was full (it can hold up to 20
  2601. entries), the oldest entry is deleted and the older entries shift one
  2602. position up (their index number is decremented by one). If the last used
  2603. entry was not at the bottom, the entries below the last used one are
  2604. deleted. This means that an old branch in the call graph is lost. After the
  2605. commands explained above the tag stack will look like this:
  2606.  
  2607.   # TO tag      FROM line in file
  2608.   1 main               1  harddisk2:text/vim/test
  2609.   2 FuncB             59  harddisk2:text/vim/src/main.c
  2610. >
  2611.  
  2612.  
  2613.     9. Inserting text
  2614.  
  2615. The following commands can be used to insert new text into the buffer. They
  2616. can all be undone. The non-Ex commands can be repeated with the "." command.
  2617.  
  2618. a            Append text after the cursor [count] times.
  2619.  
  2620. A            Append text at the end of the line [count] times.
  2621.  
  2622. i            Insert text before the cursor [count] times.
  2623.  
  2624. I            Insert text before the first CHAR on the line
  2625.             [count] times.
  2626.  
  2627. o            Begin a new line below the cursor and insert text,
  2628.             repeat [count] times. {Vi: blank [count] screen
  2629.             lines}
  2630.  
  2631. O            Begin a new line above the cursor and insert text,
  2632.             repeat [count] times. {Vi: blank [count] screen
  2633.             lines}
  2634.  
  2635. These commands are used to start inserting text. They can be undone and
  2636. repeated. You can end Insert mode with <ESC>. See the section "Insert and
  2637. Replace mode" for the other special characters in Insert mode. The effect of
  2638. [count] takes place after Insert mode is exited.
  2639.  
  2640. :r[ead] [name]        Insert the file [name] (default: current file) below
  2641.             the cursor.
  2642.  
  2643. :{range}r[ead] [name]    Insert the file [name] (default: current file) below
  2644.             the specified line.
  2645.  
  2646. :r[ead] !{cmd}        Execute {cmd} and insert its standard output below
  2647.             the cursor.
  2648.  
  2649. These commands insert the contents of a file, or the output of a command, 
  2650. into the buffer. They can be undone. They cannot be repeated with the "." 
  2651. command. They work on a line basis, insertion starts below the line in which 
  2652. the cursor is, or below the specified line. To insert text above the first 
  2653. line use the command ":0r {name}".
  2654.  
  2655. The <LF> character is recognized as end-of-line marker. If the 'textmode'
  2656. option is set, a <CR> in front of an <LF> is ignored and a CTRL-Z at the end
  2657. of the file is ignored. The 'textmode' option is default on for MSDOS.
  2658.  
  2659. If the 'textauto' option is set Vim tries to recognize the type of
  2660. end-of-line marker (see 5.2 how this is done). However, the 'textmode'
  2661. option will not be changed. Only while reading one file the text mode is
  2662. used or not.
  2663.  
  2664. On non-MSDOS systems the message "[textmode]" is shown if a file is read in
  2665. text mode, to remind you that something unusual is done. On MSDOS the
  2666. message "[notextmode]" is shown if a file is read without text mode.
  2667.  
  2668.  
  2669.     10. Deleting text
  2670.  
  2671. ["x]x            Delete [count] characters under and after the cursor
  2672.             [into register x] (not linewise).
  2673.  
  2674. ["x]X            Delete [count] characters before the cursor [into
  2675.             register x] (not linewise).
  2676.  
  2677. ["x]d{motion}        Delete text that is moved over [into register x]. 
  2678.             See below for exception.
  2679.  
  2680. ["x]dd            Delete [count] lines [into register x] (linewise).
  2681.  
  2682. ["x]D            Delete the characters under the cursor until the end
  2683.             of the line and [count]-1 more lines [into register 
  2684.             x]; synonym for d$ (not linewise).
  2685.  
  2686. {visual}["x]x    or
  2687. {visual}["x]d        Delete the highlighted text [into register x] (see
  2688.             the chapter on Visual mode). {not in Vi}
  2689.  
  2690. {visual}["x]X    or
  2691. {visual}["x]D        Delete the highlighted lines [into register x] (see
  2692.             the chapter on Visual mode). {not in Vi}
  2693.  
  2694. :[range]d[elete] [x]    Delete [range] lines (default: current line) [into
  2695.             register x].
  2696.  
  2697. :[range]d[elete] [x] {count}
  2698.             Delete {count} lines, starting with [range]
  2699.             (default: current line, see 4.4.4) [into register
  2700.             x].
  2701.  
  2702. These commands delete text. They can be repeated with the "." command
  2703. (except ":d") and undone. Use Visual mode to delete blocks of text. See
  2704. "Copying and moving text" for an explanation of registers.
  2705.  
  2706. An exception for the d{motion} command: If the motion is not linewise, the 
  2707. start and end of the motion are not in the same line and before the start 
  2708. and after the end are only blanks, the delete becomes linewise. This means 
  2709. that the blank line that would remain is also deleted.
  2710.  
  2711.  
  2712. J            Join [count] lines, with a minimum of two lines.
  2713.  
  2714. {visual}J        Join the highlighted lines, with a minimum of two
  2715.             lines. {not in Vi}
  2716.  
  2717. :[range]j[oin][!]    Join [range] lines. Same as "J", except when [!] is
  2718.             given, then no spaces will be inserted or deleted.
  2719.             When [range] is given and the start and end of the
  2720.             range are equal, nothing happens. Default is to join
  2721.             two lines.
  2722.  
  2723. :[range]j[oin][!] {count}
  2724.             Join {count} lines, starting with [range] (default:
  2725.             current line, see 4.4.4). Same as "J", except when
  2726.             [!] is given, then no spaces will be inserted or 
  2727.             deleted.
  2728.  
  2729. These commands delete the newline between lines. This has the effect of 
  2730. joining them into one line. They can be repeated (except ":j") and undone. 
  2731.  
  2732. One space is inserted in place of the <LF>, unless the line ended with a 
  2733. space, <TAB> or the next line started with a <)>. If the next line has 
  2734. leading white space it is deleted first. If the 'joinspaces' option is set, 
  2735. two spaces are inserted after a period.
  2736.  
  2737.  
  2738.     11. Changing text
  2739.  
  2740. The following commands can be used to change text, that is delete some text 
  2741. and insert something else, with one command. They can all be undone. The 
  2742. non-Ex commands can be repeated with the "." command.
  2743.  
  2744.  
  2745. 11.1 Delete and insert
  2746.  
  2747. R            Enter Replace mode: Each character you type replaces
  2748.             an existing character, starting with the character
  2749.             under the cursor. Repeat the entered text [count]-1
  2750.             times.
  2751.  
  2752. ["x]c{motion}        Delete {motion} text [into register x] and start
  2753.             insert.
  2754.  
  2755. ["x]cc            Delete [count] lines [into register x] and start
  2756.             insert (linewise). If 'autoindent' is set, preserve
  2757.             the indent of the first line.
  2758.  
  2759. ["x]C            Delete from the cursor position to the end of the
  2760.             line and [count]-1 more lines [into register x], and 
  2761.             start insert. Synonym for c$ (not linewise).
  2762.  
  2763. ["x]s            Delete [count] characters [into register x] and start
  2764.             insert (s stands for Substitute). Synonym for "cl"
  2765.             (not linewise).
  2766.  
  2767. ["x]S            Delete [count] lines [into register x] and start 
  2768.             insert. Synonym for "cc" (not linewise).
  2769.  
  2770. {visual}["x]c    or
  2771. {visual}["x]r    or
  2772. {visual}["x]s        Delete the highlighted text [into register x] and
  2773.             start insert (see the chapter on Visual mode). {not
  2774.             in Vi}
  2775.  
  2776. {visual}["x]C    or
  2777. {visual}["x]R    or
  2778. {visual}["x]S        Delete the highlighted lines [into register x] and
  2779.             start insert (see the chapter on Visual mode). {not
  2780.             in Vi}
  2781.  
  2782. You can end Insert and Replace mode with <ESC>. See the section "Insert and
  2783. Replace mode" for the other special characters in these modes. The effect of
  2784. [count] takes place after Insert or Replace mode is exited. {Vi: does not
  2785. directly delete the text, but puts a <$> at the last deleted character}
  2786. See "Copying and moving text" for an explanation of registers.
  2787.  
  2788. Replace mode is just like Insert mode, except that for every character you 
  2789. enter, one character is deleted. If the end of a line is reached, further 
  2790. characters are appended (just like Insert mode). In Replace mode the 
  2791. backspace key restores the original text (if there was any) (see section
  2792. "Insert and Replace mode").
  2793.  
  2794. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  2795. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  2796. word does not include the following white space. {Vi: "cw" when on a blank 
  2797. followed by other blanks changes only the first blank; this is probably a 
  2798. bug, because "dw" deletes all the blanks}
  2799.  
  2800.  
  2801. 11.2 Simple changes
  2802.  
  2803. r<char>            Replace the character under the cursor by <char>. If
  2804.             <char> is a <CR> or <LF> the character will be
  2805.             replaced by a line break. If a [count] is given that
  2806.             many characters will be replaced by [count] <char>s
  2807.             or line breaks {Vi: "5r<CR>" replaces five
  2808.             characters with a single line break}
  2809.  
  2810. ~            'notildeop' option: switch case of the character
  2811.             under the cursor and move the cursor to the right.
  2812.             If a [count] is given do that many characters {Vi:
  2813.             no count}
  2814.  
  2815. ~{motion}        'tildeop' option: switch case of {motion} text. {Vi: 
  2816.             tilde cannot be used as an operator}
  2817.  
  2818. {visual}~        switch case of highlighted text (see the chapter on 
  2819.             Visual mode). {not in Vi}
  2820.  
  2821. {visual}U        Make highlighted text uppercase (see the chapter on 
  2822.             Visual mode). {not in Vi}
  2823.  
  2824. {visual}u        Make highlighted text lowercase (see the chapter on 
  2825.             Visual mode). {not in Vi}
  2826.  
  2827. CTRL-A            Add [count] to the number at or after the cursor.
  2828.             {not in Vi}
  2829.  
  2830. CTRL-X            Subtract [count] from the number at or after the 
  2831.             cursor. {not in Vi}
  2832.  
  2833. The CTRL-A and CTRL-X commands work for (signed) decimal numbers and 
  2834. unsigned octal and hexadecimal numbers. Numbers starting with '0x' or '0X' 
  2835. are assumed to be hexadecimal. To decide whether the hexadecimal number 
  2836. should be printed uppercase or not, the case of the rightmost letter in the 
  2837. number is considered. If there is no letter in the current number, the 
  2838. previously detected case is used. Numbers starting with a <0> are considered 
  2839. to be octal. Other numbers are decimal and may be preceded with a minus 
  2840. sign. If the cursor is on a number, that one will be used. Otherwise the 
  2841. number right of the cursor will be used.
  2842.  
  2843. The CTRL-A command is very useful in a macro. Example: How to make a 
  2844. numbered list.
  2845.  
  2846. 1. Create the first entry. The entry should start with a number.
  2847. 2. qa        - start recording into buffer <a>
  2848. 3. Y         - yank the entry
  2849. 4. p         - put a copy of the entry below the first one
  2850. 5. CTRL-A    - increment the number
  2851. 6. q         - stop recording
  2852. 7. <count>@a - repeat the yank, put and increment <count> times
  2853.  
  2854.  
  2855. <{motion}        Shift the {motion} lines one shiftwidth leftwards.
  2856.  
  2857. <<            Shift [count] lines one shiftwidth leftwards.
  2858.  
  2859. {visual}<        Shift the highlighted lines [count] shiftwidth
  2860.             leftwards (see the chapter on Visual mode). {not in
  2861.             Vi} 
  2862.  
  2863. >{motion}        Shift {motion} lines one shiftwidth rightwards.
  2864.  
  2865. >>            Shift [count] lines one shiftwidth rightwards.
  2866.  
  2867. {visual}>        Shift the highlighted lines [count] shiftwidth
  2868.             rightwards (see the chapter on Visual mode). {not in
  2869.             Vi}
  2870.  
  2871. :[range]<        Shift [range] lines left. Repeat '<' for multiple
  2872.             shifts.
  2873.  
  2874. :[range]< {count}    Shift {count} lines left, starting with [range]
  2875.             (default current line, see 4.4.4). Repeat '<' for
  2876.             multiple shifts.
  2877.  
  2878. :[range]le[ft] [indent]    left align lines in [range]. Sets the indent in the
  2879.             lines to [indent] (default 0). {not in Vi}
  2880.  
  2881. :[range]>        Shift {count} [range] lines right. Repeat '>' for
  2882.             multiple shifts.
  2883.  
  2884. :[range]> {count}    Shift {count} lines right, starting with [range]
  2885.             (default current line, see 4.4.4). Repeat '>' for
  2886.             multiple shifts.
  2887.  
  2888. The ">" and "<" commands are handy for changing the indent within programs. 
  2889. The size of the white space which is inserted or deleted can be set with the 
  2890. 'shiftwidth' option. Normally the 'shiftwidth' option is set to 8, but you 
  2891. can set it to e.g. 3 to make smaller indents. The shift leftwards stops when 
  2892. there is no indent. The shift right does not do anything with empty lines. 
  2893.  
  2894. If the 'shiftround' option is set, the indent is rounded to a multiple of 
  2895. 'shiftwidth'.
  2896.  
  2897. If the 'smartindent' option is set, lines starting with <#> will not be
  2898. shifted right.
  2899.  
  2900. When the 'expandtab' option if off (this is the default) <TAB>s are used as 
  2901. much as possible to make the indent. You can use ">><<" to replace an indent 
  2902. made out of spaces with the same indent made out of <TAB>s (and a few 
  2903. spaces if necessary). If the 'expandtab' option is on, only spaces are 
  2904. used. Then you can use ">><<" to replace <TAB>s in the indent by spaces.
  2905.  
  2906. To move a line several 'shiftwidth's use the visual mode or the ":"
  2907. commands. For example:
  2908.     Vjj4>        move three lines 4 indents to the right
  2909.     :<<<        move current line 3 indents to the left
  2910.     :>> 5        move 5 lines 2 indents to the right
  2911.  
  2912.  
  2913. Q{motion}        Format the lines that were moved over. The length of 
  2914.             each line will be restricted to the width set with 
  2915.             the 'textwidth' option. If the 'textwidth' option is
  2916.             0, all lines will be joined together. If the
  2917.             'autoindent' option is set, the indent of the first
  2918.             line is used for the following lines. The
  2919.             'formatprg' option can be set to the name of an
  2920.             external program, which will be used instead of the
  2921.             internal function. The 'textwidth' option will then
  2922.             not be used. {not in Vi}
  2923.  
  2924. :[range]ce[nter] [width]
  2925.             Center lines in [range] between [width] columns
  2926.             (default 'textwidth' or 80 when 'textwidth' is 0).
  2927.             {not in Vi}
  2928.  
  2929. :[range]ri[ght] [width]
  2930.             right align lines in [range] at [width] columns
  2931.             (default 'textwidth' or 80 when 'textwidth' is 0).
  2932.             {not in Vi}
  2933.  
  2934.  
  2935. 11.3 Complex changes
  2936.  
  2937. !{motion}{filter}    Filter {motion} text through the external program
  2938.             {filter}.
  2939.  
  2940. !!{filter}        Filter [count] lines through the external program
  2941.             {filter}.
  2942.  
  2943. {visual}!{filter}    Filter the highlighted lines through the external
  2944.             program {filter} (see the chapter on Visual mode).
  2945.             {not in Vi}
  2946.  
  2947. :{range}![!]{filter} [!][arg]
  2948.             Filter {range} lines through the external program
  2949.             {filter}. The optional bangs are replaced with the
  2950.             latest given command. The optional [arg] is appended.
  2951.  
  2952. ={motion}        Filter {motion} lines through the external program 
  2953.             given with the 'equalprg' option (default: 
  2954.             "indent"). {Vi: when 'lisp' option is set, autoindent 
  2955.             {motion} lines}
  2956.  
  2957. ==            Filter [count] lines through the external program
  2958.             given with the 'equalprg' option (default: indent).
  2959.             {not in Vi}
  2960.  
  2961. {visual}=        Filter the highlighted lines through the external
  2962.             program given with the 'equalprg' option (default:
  2963.             indent) (see the chapter on Visual mode). {not in
  2964.             Vi}
  2965.  
  2966. A filter is a program that accepts text at standard input, changes it in some
  2967. way, and sends it to standard output. The commands above can be used to send
  2968. some text through a filter. An example of a filter is "sort", which sorts 
  2969. lines alphabetically. The "indent" program is used to pretty indent C 
  2970. programs (you need a version of indent that works like a filter, not all 
  2971. versions do that). The shell, given with the 'shell' option, is used to 
  2972. execute the command (See also the 'shelltype' option).
  2973. The filter commands can be redone with ".". There cannot be a comment (with
  2974. <">) after the ":!" command.
  2975.  
  2976.  
  2977. :[range]s[ubstitute]/{pattern}/{string}/[g][c][r] [count]
  2978.             For each line in [range] replace {pattern} by
  2979.             {string}. See below for the flags.
  2980.  
  2981. :[range]s[ubstitute] [g][c][r] [count]
  2982. :[range]&[g][c][r] [count]
  2983.             Repeat last :substitute with same search pattern and
  2984.             substitute string. The flags may be different (see
  2985.             below).
  2986.  
  2987. :[range]~[g][c][r] [count]
  2988.             Repeat last substitute with same substitute string
  2989.             but with last used search pattern. This is like
  2990.             "&r". See explanation for [r] below.
  2991.  
  2992. &            Synonym for ":s//~/" (repeat last substitute).
  2993.  
  2994. The arguments that can be given to the substitute commands:
  2995. [g]    All occurrences in the line are replaced. Otherwise only the first
  2996.     occurrence in the line is replaced. If the 'edcompatible' option is
  2997.     set this flag is remembered and toggled each time it is used. It is
  2998.     reset when a new search pattern is given. If the 'gdefault' option
  2999.     is set, this flag is default on. Give the [g] to switch it on.
  3000. [c]    Each substitute has to be confirmed. The cursor is positioned on the
  3001.     matching string. You can type <y> to substitute, <n> to skip, <q> to
  3002.     quit substituting. If the 'edcompatible' option is set this flag is
  3003.     remembered and toggled each time it is used. It is reset when a new
  3004.     search pattern is given.
  3005. [r]    When the search pattern is empty use the previously used search
  3006.     pattern instead of the search pattern from the last substitute.
  3007.     If the last command that did a search was a substitute there is no
  3008.     effect. If the last command was another search command, like
  3009.     "/" or ":global", the pattern from that command is used.
  3010. [count] That many lines are are searched, starting with the last line number
  3011.     in [range] (default current line, see 4.4.4).
  3012.  
  3013. If the {pattern} for the substitute command is empty, the pattern from the
  3014. last substitute command is used. With the [r] flag the pattern from the last
  3015. substitute or search command ("/", ":global" and the like) is used.
  3016.  
  3017. Instead of the </> which surrounds the pattern and replacement string, you
  3018. can use any other character, but not an alphanumeric character, <"> or <|>
  3019. or <#>. This is useful if you want to include a </> in the search pattern or
  3020. replacement string. Example: ":s+/+//+"
  3021.  
  3022. For the definition of a pattern see 6.5, "Pattern searches".
  3023.  
  3024. Some characters in {string} have a special meaning:
  3025.  
  3026. magic    nomagic      action
  3027.   &      \&      replaced by the whole matched pattern
  3028.  \&       &      replaced by &
  3029.       \0      replaced by the whole matched pattern
  3030.       \1      replaced by the matched pattern in the first pair of ()
  3031.       \2      replaced by the matched pattern in the second pair of ()
  3032.       ..      ..
  3033.       \9      replaced by the matched pattern in the ninth pair of ()
  3034.   ~      \~      replaced by the {string} of the previous substitute
  3035.  \~       ~      replaced by ~
  3036.       \u      next character made uppercase
  3037.       \U      following characters made uppercase
  3038.       \l      next character made lowercase
  3039.       \L      following characters made lowercase
  3040.       \e      end of /u, /U, /l and /L
  3041.       \E      end of /u, /U, /l and /L
  3042.       <CR>      split line in two at this point
  3043.   CTRL-V <CR>      insert a carriage-return (CTRL-M)
  3044.  
  3045. Examples:
  3046. :s/a\|b/xxx\0xxx/g          modifies "a b"      in "xxxaxxx xxxbxxx"
  3047. :s/\([abc]\)\([efg]\)/\2\1/g  modifies "af fa bg" in "fa fa gb"
  3048. :s/abcde/abc^Mde/          modifies "abcde"    in "abc", "de" (two lines)
  3049. :s/$/^V^M/              modifies "abcde"      in "abcde^M"
  3050.  
  3051. Note: To insert a ^M you have to type CTRL-V <CR>. To insert a ^V you have
  3052. to type CTRL-V CTRL-V. So to insert the ^V^M in the last example you have to
  3053. type CTRL-V CTRL-V CTRL-V <CR>.
  3054.  
  3055. Because CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V just
  3056. in front of a line break. You will have to split it up in two parts:
  3057.     :s/foo/^Vxxxx/
  3058.     :s/xxxx/^M/
  3059.  
  3060. When using parentheses in combination with <|>, like in \([ab]\)\|\([cd]\), 
  3061. either the first or second pattern in parentheses did not match, so either 
  3062. \1 or \2 is empty. Example:
  3063. :s/\([ab]\)\|\([cd]\)/\1x/g   modifies "a b c d"  in "ax bx x x"
  3064.  
  3065.  
  3066.     12. Copying and moving text
  3067.  
  3068. "<a-zA-Z0-9.%:">    Use register <a-zA-Z0-9.%"> for next delete, yank or
  3069.             put (use uppercase character to append with delete
  3070.             and yank) (<.> only works with put).
  3071.  
  3072. :di[splay]        Display the contents of numbered and named registers.
  3073.             {Vi: no such command}
  3074.  
  3075. ["x]y{motion}        Yank {motion} text [into register x].
  3076.  
  3077. ["x]yy            Yank [count] lines [into register x] (linewise).
  3078.  
  3079. ["x]Y            With 'noyankendofline' option: yank [count] lines 
  3080.             [into register x] (synonym for yy, linewise); with 
  3081.             'yankendofline' option: yank until end of line 
  3082.             (synonym for y$, not linewise).
  3083.  
  3084. {visual}["x]y        Yank the highlighed text [into register x] (see the 
  3085.             chapter on Visual mode). {not in Vi}
  3086.  
  3087. {visual}["x]Y        Yank the highlighted lines [into register x] (see the 
  3088.             chapter on Visual mode). {not in Vi}
  3089.  
  3090. :[range]y[ank] [x]    Yank [range] lines [into register x].
  3091.  
  3092. :[range]y[ank] [x] {count}
  3093.             Yank {count} lines, starting with last line number 
  3094.             in [range] (default: current line, see 4.4.4), [into 
  3095.             register x].
  3096.  
  3097. ["x]p            Put the text [from register x] after the cursor
  3098. [count]
  3099.             times. {Vi: no count}
  3100.  
  3101. ["x]P            Put the text [from register x] before the cursor
  3102.             [count] times. {Vi: no count}
  3103.  
  3104. :[line]pu[t] [x]    Put the text [from register x] after [line] (default
  3105.             current line).
  3106.  
  3107. :[line]pu[t]! [x]    Put the text [from register x] before [line] (default
  3108.             current line).
  3109.  
  3110. ["x]]p            like "p", but adjust the indent to the current line.
  3111.             {not in Vi}
  3112.  
  3113. ["x][p            like "P", but adjust the indent to the current line.
  3114.             {not in Vi}
  3115.  
  3116. These commands can be used to copy text from one place to another. This is 
  3117. done by first getting the text into a register with a yank, delete or change 
  3118. command. The register can then be inserted with a put command. All registers 
  3119. are kept when changing files. Thus you can also use this to move text from 
  3120. one file to another (the CTRL-^ command is a quick way to toggle between two 
  3121. files).
  3122.  
  3123. The put commands can be repeated with "." (except for :put) and undone. If the
  3124. command that was used to get the text into the register was linewise, the 
  3125. text will be inserted below ("p") or above ("P") the line where the cursor
  3126. is. Otherwise the text will be inserted after ("p") or before ("P") the
  3127. cursor. With the ":put" command the text will always be inserted in the next
  3128. line. You can exchange two characters with the command sequence "xp". You
  3129. can exchange two lines with the command sequence "ddp". You can exchange
  3130. two words with the command sequence "deep" (start with the cursor in the
  3131. blank space before the first word). The "']" or "`]" command can be used
  3132. after the put command to move the cursor to the end of the inserted text,
  3133. "'[" or "`[" to move the cursor to the start.
  3134.  
  3135. If the command that was used to get the text into the register used 
  3136. blockwise Visual mode, the block of text will be inserted before ("P") or
  3137. after ("p") the cursor column, in the current and next lines. Vim will make
  3138. the whole block of text start in the same column. Thus the inserted text
  3139. looks the same as when it was yanked or deleted. Some <TAB> characters may
  3140. be replaced by spaces to make this happen. However, if the width of the
  3141. block is not a multiple of a <TAB> width and the text after the inserted
  3142. block contains <TAB>s, that text may be misaligned.
  3143.  
  3144. There are four types of registers: The unnamed register, 10 numbered
  3145. registers, 26 named registers and two read-only registers.
  3146.     The unnamed register is the register where all text deleted with     
  3147. the "d", "c", "s", "x" commands or copied with the yank "y" command is
  3148. placed, regardless of whether or not a specific register was used (e.g.
  3149. "xdd). The contents of this register are used by any put command (p or P)
  3150. which does not specify a register. Additionally it can be accessed by the
  3151. name <">. This means you have to type two double quotes. {Vi: register
  3152. contents lost when changing files, no <">}
  3153.     The numbered registers are filled with yank and delete commands. 
  3154. Numbered register <0> is filled with the last yank command, unless another 
  3155. register was specified with ["x]. Numbered register <1> is filled with the 
  3156. text that was deleted by each delete or change command, unless another 
  3157. register was specified or the text is less than one line (text deleted with
  3158. "x" or "dw" will not be put in a numbered register). The contents of
  3159. register <1> are put in <2>, <2> in <3>, and so forth. The contents of
  3160. register <9> are lost. {Vi: numbered register contents are lost when
  3161. changing files; register 0 does not exist}
  3162.     The named registers are only filled when you say so. They are named 
  3163. <a> to <z> normally. If you use an uppercase letter, the same registers as 
  3164. with the lower case letter is used, but the text is appended to the previous 
  3165. register contents. With a lower case letter the previous contents are lost.
  3166.     The read-only registers are <%>, <:> and <.>. They can only be used
  3167. with the commands "p", "P" and ":put". <.> contains the last inserted
  3168. text (the same as what is inserted with the insert mode commands CTRL-A and
  3169. CTRL-@). <%> contains the name of the current file. <:> contains the last
  3170. command line, it can also be used with "@", "@:" repeats the last command
  3171. line.
  3172.  
  3173. If you use a put command without specifying a register, the register that 
  3174. was last written to is used (this is also the contents of the unnamed
  3175. register). If you are confused, use the ":dis" command to find out what will
  3176. be put (all named and numbered registers are displayed; the unnamed register
  3177. is labelled <">).
  3178.  
  3179. The next three commands always work on whole lines.
  3180.  
  3181. :[range]co[py] {address}
  3182.             Copy the lines given by [range] to below the line
  3183.             given by {address}.
  3184.  
  3185. :t            Synonym for copy.
  3186.  
  3187. :[range]m[ove] {address}
  3188.             Move the lines given by [range] to below the line
  3189.             given by {address}.
  3190.  
  3191.  
  3192.     13. Visual mode
  3193.  
  3194. Visual mode is a flexible and easy way to select a piece of text for an 
  3195. operator. It is the only way to select a block of text.
  3196.  
  3197. v            start/stop Visual mode per character. {not in Vi}
  3198.  
  3199. V            start/stop Visual mode linewise. {not in Vi}
  3200.  
  3201. CTRL-V            start/stop Visual mode blockwise. {not in Vi}
  3202.  
  3203. o            go to Other end of highlighted text: The current
  3204.             cursor position becomes the start of the highlighted
  3205.             text and the cursor is moved to the Other end of the
  3206.             highlighted text. {not in Vi} 
  3207.  
  3208. To apply an operator on a piece of text:
  3209.     1. mark the start of the text with "v", "V" or CTRL-V
  3210.         The character under the cursor will be used as the start.
  3211.     2. move to the end of the text
  3212.         The text from the start of the Visual mode up to and
  3213.         including the character under the cursor is highlighted.
  3214.     3. hit an operator
  3215.         The highlighted characters will be operated upon.
  3216.  
  3217. The 'highlight' option can be used to set the display mode to use for
  3218. highlighting in Visual mode.
  3219.  
  3220. The highlighted text includes the character under the cursor. On terminals
  3221. where it is possible to make the cursor invisible the cursor position is
  3222. also highlighted. On terminals where this is not possible the cursor is
  3223. displayed normally. If your cursor cannot be made invisible and you want Vim
  3224. to highlight the character under the cursor anyway, you could set the 't_cv'
  3225. and 't_ci' options to something harmless, for example:
  3226.         :set t_cv=^[^[ t_ci=^[^[
  3227.  
  3228. With "v" the text before the start position and after the end position will 
  3229. not be highlighted. However, All uppercase and non-alpha operators, except 
  3230. "~", will work on whole lines anyway. See the list of operators below.
  3231.  
  3232. With CTRL-V (blockwise Visual mode) the highlighted text will be a rectangle
  3233. between start position and the cursor. However, some operators work on whole
  3234. lines anyway (see the list below). The change and substitute operators will
  3235. delete the highlighted text and then start insertion at the top left
  3236. position. 
  3237.  
  3238. When the "$" command is used with blockwise Visual mode, the right end of the 
  3239. highlighted text will be determined by the longest highlighted line. This
  3240. stops when a motion command is used that does not move straight up or down.
  3241.  
  3242. If you use "v", "V", CTRL-V, ESC or any command that does a jump to another
  3243. window while in Visual mode, the highlighting stops and no text is affected.
  3244. If you hit CTRL-Z the highlighting stops and the editor is suspended or a new
  3245. shell is started.
  3246.  
  3247. For moving the end of the block many commands can be used, but you cannot 
  3248. use Ex commands, commands that make changes or abandon the file. Commands 
  3249. (starting with) ".pPiIaAO&", CTRL_^, "ZZ", CTRL-], CTRL-T, CTRL-R, CTRL-I 
  3250. and CTRL-O cause a beep and Visual mode continues. 
  3251.  
  3252. If the "v", "V" or CTRL-V is preceded with a count, the previously
  3253. highlighted area is used for a start. You can then move the end of the
  3254. highlighted area and give an operator. The type of the old area is used
  3255. (character, line or blockwise).
  3256. - Linewise Visual mode: The number of lines is multiplied with the count.
  3257. - Blockwise Visual mode: The number of lines and columns is multiplied with
  3258.   the count.
  3259. - Normal Visual mode within one line: The number of characters is multiplied
  3260.   with the count.
  3261. - Normal Visual mode with several lines: The number of lines is multiplied
  3262.   with the count, in the last line the same number of characters is used as
  3263.   in the last line in the previously highlighted area.
  3264. The start of the text is the Cursor position. If the "$" command was used as 
  3265. one of the last commands to extend the highlighted text, the area will be
  3266. extended to the rightmost column of the longest line.
  3267.  
  3268. The operators that can be used are:
  3269.     ~    switch case
  3270.     d    delete
  3271.     c    change
  3272.     y    yank
  3273.     >    shift right (1)(*)
  3274.     <    shift left (1)(*)
  3275.     !    filter through external command (1)
  3276.     =    filter through 'equalprg' option command (1)
  3277.     Q    format lines to 'textwidth' length (1)
  3278.  
  3279. Additionally the following commands can be used:
  3280.     :    start ex command for highlighted lines (1)
  3281.     r    change
  3282.     s    change
  3283.     C    change (2)
  3284.     R    change (2)
  3285.     S    change (2)
  3286.     x    delete
  3287.     D    delete (2)
  3288.     X    delete (2)
  3289.     Y    yank (2)
  3290.     J    join (1)
  3291.     U    make uppercase
  3292.     u    make lowercase
  3293.  
  3294. (1): always whole lines
  3295. (2): whole lines when not using CTRL-V
  3296. (*): in a future a blockwise shift will move the block only, not whole
  3297.      lines.
  3298.  
  3299. If you want to give a register name using the """ command, do this just before 
  3300. typing the operator character: "v{move around}"xd".
  3301.  
  3302. If you want to give a count to the command, do this just before typing the
  3303. operator character: "v{move around}3>" (move lines 3 indents to the right).
  3304.  
  3305. When repeating a Visual mode operator, the operator will be applied to the
  3306. same amount of text as the last time:
  3307. - Linewise Visual mode: The same number of lines.
  3308. - Blockwise Visual mode: The same number of lines and columns.
  3309. - Normal Visual mode within one line: The same number of characters.
  3310. - Normal Visual mode with several lines: The same number of lines, in the
  3311.   last line the same number of characters as in the last line the last time.
  3312. The start of the text is the Cursor position. If the "$" command was used as 
  3313. one of the last commands to extend the highlighted text, the repeating will
  3314. be applied up to the rightmost column of the longest line.
  3315.  
  3316.  
  3317.     14. Various commands
  3318.  
  3319. CTRL-L            Clear and redraw the screen.
  3320.  
  3321. CTRL-Z            On Unix systems: Suspend Vim. On other systems: 
  3322.             start a new shell (like ":sh").
  3323.  
  3324. <HELP>        or
  3325. :h[elp]            Show the help file page by page. The help file name 
  3326.             can be set with the 'helpfile' option. Type an index
  3327.             character to go directly to a page. Type <SPACE> or
  3328.             CTRL-F (with MSDOS: page-down) to go one page
  3329.             forward. Type <b> or CTRL-B (with MSDOS: page-up) to
  3330.             go one page back. Type <a> to go back to the index.
  3331.             Type <CR> to get out of the help screen. {Vi: no
  3332.             help}
  3333.  
  3334. <DEL>            When entering a number: remove the last digit.
  3335.  
  3336. :[range]p[rint]        Print [range] lines (default current line).
  3337.  
  3338. :[range]p[rint] {count}
  3339.             Print {count} lines, starting with [range] (default
  3340.             current line, see 4.4.4).
  3341.  
  3342. :[range]l[ist] [count]
  3343.             Same as :print, but display unprintable characters
  3344.             with <^>.
  3345.  
  3346. :[range]nu[mber] [count]
  3347.             Same as :print, but precede each line with its line
  3348.             number.
  3349.  
  3350. :[range]# [count]    synonym for :number.
  3351.  
  3352. :=            Print the line number.
  3353.  
  3354. :sh[ell]        Escape to a shell (name from 'shell' option).
  3355.  
  3356. :![!]{cmd} [!][arg]    Execute {cmd} with the shell. The optional bangs are
  3357.             replaced with the previously given command. The 
  3358.             optional [arg] is appended. See also the 'shell' and 
  3359.             'shelltype' option.
  3360.  
  3361. :ve[rsion]        Print the version number of the editor. If the
  3362.             compiler used understands "__DATE__" the compilation
  3363.             date is mentioned. Otherwise a fixed release-date is
  3364.             shown.
  3365.  
  3366. K            Run a program to lookup the identifier under the 
  3367.             cursor. The name of the program is given with the 
  3368.             'keywordprg' (kp) option (default is "ref"). The
  3369.             identifier is formed of letters, numbers and the
  3370.             underscore. The identifier under or right of the
  3371.             cursor is used. The same can be done with the
  3372.             command
  3373.                 ":!{program} {identifier}". 
  3374.             There is an example of a program to use in the tools
  3375.             directory of Vim. It is called 'ref' and does a
  3376.             simple spelling check. {not in Vi}
  3377.  
  3378. [N]gs
  3379. :[N]sleep [N]        Do nothing for [N] seconds. Can be interrupted with
  3380.             CTRL-C (CTRL-break on MSDOS). "gs" stands for "goto
  3381.             sleep". {not in Vi}
  3382.  
  3383.  
  3384.     15. Repeating commands
  3385.  
  3386. 15.1 Single repeats
  3387.  
  3388. .            Repeat last change with count replaced by [count].
  3389.  
  3390. Simple changes can be repeated with the "." command. Without a count, the 
  3391. count of the last change is used. If you enter a count, it will replace the 
  3392. last one. If the last change included a specification of a numbered 
  3393. register, the register number will be incremented. See the section on undo 
  3394. and redo for an example how to use this.
  3395.  
  3396.  
  3397. 15.2 Multiple repeats
  3398.  
  3399. :[range]g[lobal]/{pattern}/[cmd]
  3400.             Execute the Ex command [cmd] (default ":p") on the
  3401.             lines within [range] where {pattern} matches.
  3402.  
  3403. :[range]g[lobal]!/{pattern}/[cmd]
  3404.             Execute the Ex command [cmd] (default ":p") on the
  3405.             lines within [range] where {pattern} does NOT match.
  3406.  
  3407. :[range]v[global]/{pattern}/[cmd]
  3408.             Same as :g!.
  3409.  
  3410. The global commands work by first scanning through the [range] lines and
  3411. marking each line where a match occurs. In a second scan the [cmd] is 
  3412. executed for each marked line with its line number prepended. If a line is 
  3413. changed or deleted its mark disappears. The default for [range] is the whole 
  3414. buffer (1,$). Use "CTRL-C" to interrupt the command. If an error message is
  3415. given for a line global aborts.
  3416.  
  3417. To repeat a non-Ex command, you will have to put the command in a file and 
  3418. use "source!". For example:
  3419.     :g/pat/so! scriptfile
  3420. Make sure that the scriptfile ends with a whole command, otherwise Vim will 
  3421. wait for you to type the rest of the command for each match. The screen will 
  3422. not have been updated, so you don't know what you are doing.
  3423.     
  3424. The undo/redo command will undo/redo the whole global command at once.
  3425.  
  3426.  
  3427. 15.3 Complex repeats
  3428.  
  3429. q<0-9a-zA-Z">        Record typed characters into register <0-9a-zA-Z">
  3430.             (uppercase to append). The 'q' that stops recording
  3431.             is also stored in the register. The 'q' command is
  3432.             disabled while executing a register. (Implementation
  3433.             note: This was done because the 'q' command can be
  3434.             the result of mapping). {Vi: no recording}
  3435.  
  3436. q            Stops recording. {Vi: no recording}
  3437.  
  3438. @<0-9a-z">        Execute the contents of register <0-9a-z"> [count]
  3439.             times. {Vi: only named registers}
  3440.  
  3441. @:            Repeat last command line [count] times.
  3442.  
  3443. @@            Repeat the previous @<0-9a-z":> [count] times.
  3444.  
  3445. :[addr]@<0-9a-z">    Execute the contents of register <0-9a-z"> as
  3446.             an Ex command. First set cursor at line [addr]
  3447.             (default is current line). {Vi: only in some
  3448.             versions}
  3449.  
  3450. :[addr]@:        Repeat last command line [count] times. First set
  3451.             cursor at line [addr] (default is current line).
  3452.             {Vi: only in some versions}
  3453.  
  3454. :[addr]@@        Repeat the previous :@<0-9a-z">. First set cursor at
  3455.             line [addr] (default is current line). {Vi: only in
  3456.             some versions}
  3457.  
  3458. :so[urce] {file}    Read Ex commands from {file}.
  3459.  
  3460. :so[urce]! {file}    Read Vim commands from {file}. {not in Vi}
  3461.  
  3462. All commands and command sequences can be repeated by putting them in a named
  3463. register and then executing it. There are two ways to get the commands in the
  3464. register:
  3465. - Use the record command "q". You type the commands once, and while they are
  3466.   being executed they are stored in a register. Easy, because you can see 
  3467.   what you are doing. If you make a mistake, 'put' the register into the 
  3468.   file, edit the command sequence, and then delete it into the register 
  3469.   again. You can continue recording by appending to the register (use an 
  3470.   uppercase letter).
  3471. - Delete or yank the command sequence into the register.
  3472.  
  3473. Often used command sequences can be put under a function key with the ':map'
  3474. command.
  3475.  
  3476. An alternative is to put the commands in a file, and execute them with the
  3477. ':source!' command. Useful for long command sequences. Can be combined with 
  3478. the ':map' command to put complicated commands under a function key.
  3479.  
  3480. The ':source' command reads Ex commands from a file line by line. You will 
  3481. have to type any needed keyboard input. The ':source!' command reads from a 
  3482. script file character by character, interpreting each character as if you 
  3483. typed it.
  3484.  
  3485. Example: When you give the ":!ls" command you are asked to "hit return to
  3486. continue". If you ':source' a file with the line "!ls" in it, you will have 
  3487. to type the return yourself. But if you ':source!' a file with the line 
  3488. ":!ls" in it, the next characters from that file are read until a <CR> is 
  3489. found. You will not have to type <CR> yourself, unless ":!ls" was the last 
  3490. line in the file.
  3491.  
  3492. It is possible to put ':source[!]' commands in the script file, so you can 
  3493. make a top-down hierarchy of script files. The ':source' command can be 
  3494. nested as deep as the number of files that can be opened at one time (about 
  3495. 15). The ':source!' command can be nested up to 15 levels deep.
  3496.  
  3497. In script files terminal-dependent key codes are represented by 
  3498. terminal-independent single character codes. In the MSDOS version the values
  3499. are 48 (0x30) higher. Any of these codes can be entered with CTRL-V followed
  3500. by the three digit decimal code.
  3501.  
  3502.     code    hex    meaning
  3503.  
  3504.     128    0x80    up-arrow
  3505.     129    0x81    down-arrow
  3506.     130    0x82    left-arrow
  3507.     131    0x83    right-arrow
  3508.     132    0x84    shift up-arrow
  3509.     133    0x85    shift down-arrow
  3510.     134    0x86    shift left-arrow
  3511.     135    0x87    shift right-arrow
  3512.  
  3513.     136    0x88    function key 1
  3514.     137    0x89    function key 2
  3515.     138    0x8a    function key 3
  3516.     139    0x8b    function key 4
  3517.     140    0x8c    function key 5
  3518.     141    0x8d    function key 6
  3519.     142    0x8e    function key 7
  3520.     143    0x8f    function key 8
  3521.     144    0x90    function key 9
  3522.     145    0x91    function key 10
  3523.  
  3524.     146    0x92    shifted function key 1
  3525.     147    0x93    shifted function key 2
  3526.     148    0x94    shifted function key 3
  3527.     149    0x95    shifted function key 4
  3528.     150    0x96    shifted function key 5
  3529.     151    0x97    shifted function key 6
  3530.     152    0x98    shifted function key 7
  3531.     153    0x99    shifted function key 8
  3532.     154    0x9a    shifted function key 9
  3533.     155    0x9b    shifted function key 10
  3534.  
  3535.     156    0x9c    help key
  3536.     157    0x9d    undo key
  3537.     158    0x9e    special-function key follows (MSDOS)
  3538.     159    0x9f    CTRL-@
  3539.  
  3540.  
  3541.     16. Undo and redo
  3542.  
  3543. <UNDO>        or
  3544. u            Undo [count] changes. {Vi: only one level}
  3545.  
  3546. :u[ndo]            Undo one change. {Vi: only one level}
  3547.  
  3548. CTRL-R            Redo [count] changes which were undone. {Vi: redraw 
  3549.             screen}
  3550.  
  3551. :red[o]            Redo one change which was undone. {Vi: no redo}
  3552.  
  3553. U            Undo all latest changes on one line. {Vi: while not
  3554.             moved off of it}
  3555.  
  3556. The last changes are remembered. You can go back in time with the "u" 
  3557. command. You can then go forward again with the 'CTRL-R' command. If you 
  3558. make a new change after the "u" command, the 'CTRL-R' will not be possible 
  3559. anymore. The number of changes that are remembered is set with the 
  3560. 'undolevels' option. If it is zero, the old fashioned Vi undo is present: 
  3561. one level of undo and undo undoes itself. If it is negative no undo is
  3562. possible. Use this if you are running out of memory.
  3563.  
  3564. The "U" command is treated by undo/redo just like any other command. Thus a 
  3565. "u" command undos a "U" command and a 'CTRL-R' command redoes it again. When 
  3566. mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will 
  3567. restore the situation of a line to before the previous "U" command. This may 
  3568. be confusing. Try it out to get used to it.
  3569.  
  3570. When all changes have been undone the buffer is not considered to be changed.
  3571. Vim can then be exit with ":q" instead of ":q!". {this is not in Vi}
  3572.  
  3573. The numbered registers can also be used for undoing deletes. Each time you 
  3574. delete text, it is put into register "1. The contents of register "1 are 
  3575. shifted to "2, etc. The contents of register "9 are lost. You can now get
  3576. back the most recent deleted text with the put command: '"1P'. (also, if the
  3577. deleted text was the result of the last delete or copy operation, 'P' or 'p'
  3578. also works as this puts the contents of the unnamed register). You can get
  3579. back the text of three deletes ago with '"3P'.
  3580.  
  3581. If you want to get back more than one part of deleted text, you can use a
  3582. special feature of the repeat command ".". It will increase the number of the
  3583. register used. So if you first do ""1P", the following "." will result in a
  3584. '"2P'. Repeating this will result in all numbered registers being inserted.
  3585.  
  3586. Example:    If you deleted text with 'dd....' it can be restored with
  3587.         '"1P....'.
  3588.  
  3589. If you don't know in which register the deleted text is, you can use the
  3590. :display command. An alternative is to try the first register with '"1P', and
  3591. if it is not what you want do 'u.'. This will remove the contents of the
  3592. first put, and repeat the put command for the second register. Repeat the
  3593. 'u.' until you got what you want.
  3594.  
  3595.  
  3596.     17. Key mapping
  3597.  
  3598. :map {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Command mode.
  3599.  
  3600. :map! {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Insert and
  3601.             Command_line mode.
  3602.  
  3603. :noremap {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Command mode. 
  3604.             Disallow remapping of {rhs}. {not in Vi}
  3605.  
  3606. :noremap! {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in insert and
  3607.             Command_line mode. Disallow remapping of {rhs}. {not 
  3608.             in Vi}
  3609.  
  3610. :unm[ap] {lhs}        Remove the mapping of {lhs} for Command mode.
  3611.  
  3612. :unm[ap]! {lhs}        Remove the mapping of {lhs} for Insert and
  3613.             Command_line mode.
  3614.  
  3615. :map            List all key mappings for Command mode.
  3616.  
  3617. :map!            List all key mappings for Insert and Command_line
  3618.             mode.
  3619.  
  3620. :map {lhs}        List the key mappings for the key sequences starting
  3621.             with {lhs} in Command mode. {not in Vi}
  3622.  
  3623. :map! {lhs}        List the key mappings for the key sequences starting
  3624.             with {lhs} in insert and Command_line mode. {not in Vi}
  3625.  
  3626. :cm[ap]            Same as :map, but for Command_line mode only. {not
  3627.             in Vi}
  3628.  
  3629. :cu[nmap]        Same as :unmap, but for Command_line mode only.
  3630.             {not in Vi}
  3631.  
  3632. :cno[remap]        Same as :noremap, but for Command_line mode only.
  3633.             {not in Vi}
  3634.  
  3635. :im[ap]            Same as :map, but for Insert mode only. {not in Vi}
  3636.  
  3637. :iu[nmap]        Same as :unmap, but for Insert mode only. {not in
  3638.             Vi}
  3639.  
  3640. :ino[remap]        Same as :noremap, but for Insert mode only. {not in
  3641.             Vi}
  3642.  
  3643. These commands are used to map a key or key sequence to a string of 
  3644. characters. You can use this to put command sequences under function keys, 
  3645. translate one key into another, etc. See the "Options" chapter below for how 
  3646. to save and restore the current mapping.
  3647.  
  3648. There are three sets of mappings
  3649. - For Insert mode. These are also used in Replace mode.
  3650. - For Command_line mode: When entering a ":" or "/" command.
  3651. - For Command mode: When typing commands.
  3652.  
  3653. The original vi did not have separate mappings for Insert mode and
  3654. Command_line mode. Therefore the ":map!" command enters and displays
  3655. mappings for both. In Vim you can use the ":cmap" and ":imap" commands to
  3656. enter mappings for each mode separately. When listing mappings with ":map!",
  3657. ":cmap" or ":imap" the character in column 1 is <!> for mappings in both
  3658. Insert and Command_line mode, <i> for Insert mode only and <c> for
  3659. Command_line mode only.
  3660.  
  3661. Everything from the first non-blank after {lhs} up to the end of the line
  3662. (or <|>) is considered to be part of {rhs}. This allows the {rhs} to end
  3663. with a space.
  3664.  
  3665. To include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for 
  3666. each space). If you want a {rhs} that starts with a space, precede {rhs} 
  3667. with a single CTRL-V (You have to type CTRL-V two times). You can create an 
  3668. empty {rhs} by typing nothing after the two CTRL-Vs.
  3669.  
  3670. It is not possible to put a comment after this command, because the <"> 
  3671. character is considered to be part of the {rhs}. To put a <|> in {rhs} 
  3672. escape it with a backslash or a CTRL-V (to get one CTRL-V you have to type 
  3673. it twice).
  3674.  
  3675. To avoid mapping of the characters you type in insert or Command_line mode, 
  3676. type a CTRL-V first. The mapping in Insert mode is disabled if the 'paste'
  3677. option is set.
  3678.  
  3679. Note that the second character (argument) of the commands @zZtTfF[]rm'`"v is
  3680. not mapped. This was done to be able to use all the named registers and
  3681. marks, even when the command with the same name has been mapped.
  3682.  
  3683. Some examples (given as you type them; e.g. the "^V" is CTRL-V which you 
  3684. type, but will not show up on the screen):
  3685.  
  3686.     :map g /foo^V^Mcwbar^V^[    (replace next "foo" by "bar")
  3687.     :map! qq quadrillion questions
  3688.  
  3689. Vim will compare what you type with the start of a mapped sequence. If there
  3690. is an incomplete match, it will get more characters until there either is a
  3691. complete match or until there is no match at all. Example: If you map! "qq",
  3692. the first <q> will not appear on the screen until you type another
  3693. character. This is because Vim cannot know if the next character will be a
  3694. <q> or not. If you set the 'timeout' option (which is the default) Vim will
  3695. only wait for one second (or as long as specified with the 'timeoutlen'
  3696. option). After that it assumes that the <q> is to be interpreted as such. If
  3697. type slowly, or your system is slow, reset the 'timeout' option. Then you
  3698. might want to set the 'ttimeout' option. See the "Options" chapter.
  3699.  
  3700. If you want to exchange the meaning of two keys you should use the :noremap 
  3701. command. For example:
  3702.     :noremap k j
  3703.     :noremap j k
  3704. This will exchange the cursor up and down commands. With the normal :map 
  3705. command, when the 'remap' option is set, mapping takes place until the text 
  3706. is found not to be a part of a {lhs}. For example, if you use:
  3707.     :map x y
  3708.     :map y x
  3709. Vim will replace x by y, and then y by x, etc. When this has happened 1000 
  3710. times, Vim will give an error message.
  3711.  
  3712. See the file "index" for keys that are not used and thus can be mapped 
  3713. without losing any builtin function.
  3714.  
  3715. If you include an undo command inside a mapped sequence, this will bring the 
  3716. text back in the state before executing the macro. This is compatible with 
  3717. the original vi, as long as there is only one undo command in the mapped 
  3718. sequence (having two undo commands in a mapped sequence did not make sense 
  3719. in the original vi, you would get back the text before the first undo).
  3720.  
  3721. There are two ways to map a function key:
  3722. 1. The vi-compatible method: Map the key code. Often this is a sequence that
  3723.    starts with <ESC>. To enter a mapping like this you type ":map " and then
  3724.    you have to type CTRL-V before hitting the function key.
  3725. 2. The second method is to use the internal code for the function key. To
  3726.    enter such a mapping just hit the function key, without CTRL-V, or use
  3727.    the form "#1", "#2", .. "#9", "#0". Only the first ten function keys can
  3728.    be used this way ("#0" refers to function key 10, defined with option
  3729.    't_f10', which may be function key zero on some keyboards).
  3730. The advantage of the second method is that the mapping will mostly work on
  3731. different terminals without modification (the function key will be
  3732. translated into the same internal code, no matter what terminal you are
  3733. using. The termcap must be correct for this to work, and you must use the
  3734. same mappings).
  3735.  
  3736. DETAIL: Vim first checks if a sequence from the keyboard is mapped. If it
  3737. isn't the terminal key codes are tried (see section 20.2). If a terminal
  3738. code is found it is replaced by the internal code. Then the check for a
  3739. mapping is done again (so you can map an internal code to something else).
  3740. What is written into the script file depends on what is recognized. If the
  3741. terminal key code was recognized as a mapping the key code itself is written
  3742. to the script file. If it was recognized as a terminal code the internal
  3743. code is written to the script file.
  3744.  
  3745.  
  3746.     18. Recovery after a crash.
  3747.  
  3748. You have spent several hours typing in that text that has to be finished
  3749. next morning, and then disaster strikes: Your computer crashes.
  3750.  
  3751.             DON'T PANIC!
  3752.  
  3753.  
  3754. 18.1 The swap file
  3755.  
  3756. Vim stores the things you changed in a swap file. Using the original file
  3757. you started from plus the swap file you can mostly recover your work. You
  3758. can see the name of the current swap file being used with the command:
  3759.  
  3760.     :sw[apname]
  3761.  
  3762. The name of the swap file is normally the same as the file you are editing, 
  3763. with the extension ".swp". On MSDOS machines and when the 'shortname' option 
  3764. is set, any <.> in the original file name is replaced by <_>. If this file
  3765. already exists (e.g. when you are recovering from a crash) a warning is
  3766. given and another extension is used, ".swo", ".swn", etc. An existing file
  3767. will never be overwritten. The swap file is deleted as soon as Vim stops
  3768. editing the file.
  3769.  
  3770. Technical: The replacement of <.> by <_> is done to avoid problems with 
  3771.        MSDOS compatible filesystems (e.g. crossdos, multidos). If Vim is 
  3772.        able to detect that the file is on an MSDOS-like filesystem, a 
  3773.        flag is set that has the same effect as the 'shortname' option. 
  3774.        This flag is reset when you start editing another file.
  3775.  
  3776.        If the ".swp" filename already exists, the last character is 
  3777.        decremented until there is no file with that name or ".swa" is 
  3778.        reached. In the last case, no swap file is created.
  3779.  
  3780. By setting the 'directory' option you can place the swap file in
  3781. another place than where the edited file is. The advantage is that you will
  3782. not pollute the directories with ".swp" files and, when the 'directory' is
  3783. on another partition, reduce the risk of damaging the file system where the
  3784. file is (in a crash). The tradeoff is that you can get name collisions from
  3785. files with the same name but in different directories. You can also use a
  3786. recoverable ram disk, but there is no 100% guarantee that this works.
  3787. Putting swap files in a normal ram disk (like RAM: on the Amiga) makes no
  3788. sense, you will loose them in a crash. If you want to put swap files in
  3789. another place, put a command resembling the following one in your .vimrc:
  3790.     :set dir=dh2:tmp
  3791. This is also very handy when editing files on floppy.
  3792.  
  3793. The swap file is updated after typing 200 characters or when you have 
  3794. not typed anything for four seconds. This only happens if the buffer was 
  3795. changed, not when you only moved around. The reason why it is not kept up to 
  3796. date all the time is that this would slow down normal work too much. You can 
  3797. change the 200 character count with the 'updatecount' option. You can set 
  3798. the time with the 'updatetime' option. The time is given in milliseconds.
  3799.  
  3800. If the writing to the swap file is not wanted, it can be switched off by
  3801. setting the 'updatecount' option to 0. The same is done when starting Vim 
  3802. with the "-n" or "-v" option. Writing can be switched back on by setting the 
  3803. 'updatecount' option to non-zero. But this will only affect files that will
  3804. be opened after this.
  3805.  
  3806. If you want to make sure that your changes are in the swap file use this
  3807. command:
  3808.  
  3809. :pres[erve]        Write all text for all buffers into swap file. {Vi:
  3810.             emergency exit}
  3811.  
  3812. A Vim swap file can be recognized by the first six characters: "b0VIM ".
  3813. After that comes the version number, e.g. "3.0".
  3814.  
  3815.  
  3816. 18.2 Recovery
  3817.  
  3818. In most cases recovery is quite easy: Start Vim on the same file you were
  3819. editing when the crash happened, with the "-r" option added. Vim will read
  3820. the ".swp" file and may read bits and pieces of the original file.
  3821.  
  3822. Example:    vim -r reference.doc
  3823.  
  3824. If the swap file does not end in ".swp" but in something else, you can
  3825. recover by giving the swap file name. Vim will then find out the name of the
  3826. original file from the swap file.
  3827.  
  3828. Example:    Vim -r reference.doc.swp
  3829.  
  3830. This is also handy when the swap file is in another directory than expected.
  3831. If this still does not work, see what file names Vim reports and rename the
  3832. files accordingly. 
  3833.  
  3834. There is some intelligence about what to do if the swap file is corrupt in
  3835. some way. If Vim has doubt about what it found, it will give an error
  3836. message and insert lines with "???" in the text. If you see an error message
  3837. while recovering, search in the file for "???" to see what is wrong. You may
  3838. want to cut and paste to get the text you need.
  3839.  
  3840. Be sure that the recovery was successful before overwriting the original
  3841. file or deleting the swap file. It is good practice to write the recovered
  3842. file elsewhere and execute 'diff' to find out if the changes you want are in
  3843. the recovered file.
  3844.  
  3845. Once you are sure the recovery is ok delete the swap file. Otherwise, you
  3846. will continue to get warning messages that the ".swp" file already exists.
  3847.  
  3848. {Vi: recovers in another way and sends mail if there is something to recover}
  3849.  
  3850.  
  3851.     19. Options
  3852.  
  3853. Vi has a number of internal variables and switches which can be set to 
  3854. achieve special effects. These options come in three forms, those that are 
  3855. switches, which toggle from off to on and back, those that require a numeric 
  3856. value, and those that require an alphanumeric string value.
  3857.  
  3858.  
  3859. 19.1 Setting options
  3860.  
  3861. :se[t]            Show all modified options. {Vi: non-default options}
  3862.  
  3863. :se[t] all        Show all but terminal options.
  3864.  
  3865. :se[t] termcap        Show all terminal options.
  3866.  
  3867. :se[t] {option}        Set toggle option on, show value of string or number
  3868.             option.
  3869.  
  3870. :se[t] no{option}    Set toggle option off.
  3871.  
  3872. :se[t] inv{option}    Invert toggle option. {not in Vi}
  3873.  
  3874. :se[t] {option}={value} Set string or number option to {value}.
  3875.  
  3876. :se[t] {option}?    Show value of {option}.
  3877.  
  3878. The {option} arguments to ":set" may be repeated. For example:
  3879.     ":set ai nosi sw=3 ts=3".
  3880. If you make an error in one of the arguments an error message will be given
  3881. and the text up to the next space will be skipped. Thus following arguments
  3882. will be processed.
  3883.  
  3884. The listing from ":set" looks different from vi. Long string options are put
  3885. at the end of the list. The number of options is quite large. The output of
  3886. "set all" probably does not fit on the screen, causing Vim to give the
  3887. "--more--" message. See the 'more' option.
  3888.  
  3889. An environment variable in most string options will be expanded. This
  3890. happens only when the string starts with a <$>. If the environment variable
  3891. exists the <$> and the following environment variable name is replaced by
  3892. its value. If it does not exist the <$> and the name are not modified. Any
  3893. non-id character (not a letter, digit or <_>) may follow the environment
  3894. variable name. That character and what follows is appended to the value of
  3895. the environment variable. Example:
  3896.     :set term=$TERM.new
  3897.  
  3898. Using "~/" is like using "$HOME".
  3899.  
  3900. Besides changing options with the ":set" command, there are four 
  3901. alternatives to set options automatically for one or more files. The first 
  3902. and second ones are used for all files. The third is used to set options for 
  3903. the files in one directory. The last is used to set options for a single 
  3904. file. The first three are done when you start Vim, in the given order. The 
  3905. last is done whenever you start editing a new file.
  3906.  
  3907. 1. The environment variable VIMINIT is read for an Ex command. You can set
  3908.    VIMINIT to something like "set noai sw=3" to set options.
  3909. 2. Only if there is no VIMINIT environment variable, the file 
  3910.    "s:.vimrc" is read for Ex commands. You can include set commands in this 
  3911.    file. (see below for how to automatically create a file with set commands).
  3912. 3. If VIMINIT is not found and "s:.vimrc" does not exist, EXINIT is used, 
  3913.    in the same way as VIMINIT.
  3914. 4. If VIMINIT is not found, "s:.vimrc" does not exist and EXINIT is not found, 
  3915.    the file "s:.exrc" is read for Ex commands.
  3916. 5. If the 'exrc' option is set, the file ".vimrc" in the current directory is 
  3917.    read for Ex commands. You can include set commands in this file. If this 
  3918.    file is not found the file ".exrc" is tried.
  3919. 6. If you start editing a new file, and the 'modeline' option is set, a
  3920.    number of lines at the beginning and end of the file are checked for the
  3921.    string "vi:", "vim:" or "ex:". The text after it is considered to be the
  3922.    arguments for a ":set" command, separated with colons or spaces. For
  3923.    example:
  3924.            "vi:noai:sw=3 ts=6"
  3925.    The number of lines that are checked can be set with the 'modelines'
  3926.    option. If 'modeline' is not set or 'modelines' is 0 no lines are
  3927.    checked.
  3928.    The string "vi:", "vim:" or "ex:" must be preceded with a blank or begin 
  3929.    at the start of a line. This minimizes the chance that a normal word like 
  3930.    "lex:" is caught.
  3931.    Note that all of the rest of the line is used, thus a line like:
  3932.            "/* vi:ts=4: */"
  3933.    will give an error message for the trailing "*/".
  3934.    If an error is detected the rest of the line is skipped.
  3935.    One other form of modelines is recognized that has the "set" command
  3936.    after "vi:", "vim:" or "ex:" (this is compatible with some versions of
  3937.    vi). In this case the characters up to the first <:> are executed as an
  3938.    ex command. Anything following it is ignored. Thus a line like:
  3939.            "/* vi:set ts=4: */"
  3940.    is OK. If you want to include a <:> in a set command precede it with a
  3941.    <\>.
  3942.  
  3943.  
  3944. 19.2 Saving settings
  3945.  
  3946. :mkexrc [file]        Write current key mappings and changed options to 
  3947.             [file] (default ".exrc"), unless it already exists. 
  3948.             {not in Vi}
  3949.  
  3950. :mkexrc! [file]        Always write current key mappings and changed 
  3951.             options to [file] (default ".exrc"). {not in Vi}
  3952.  
  3953. :mkvimrc[!] [file]    Same as :mkexrc, but default is ".vimrc". {not in 
  3954.             Vi}
  3955.  
  3956. These commands will write ":map" and ":set" commands to a file, in such a 
  3957. way that when these commands are executed, the current key mappings and 
  3958. options will be set again. A common method is to use a default ".exrc" file 
  3959. by first reading one in with ":source s:.exrc.Cprogs", change the settings 
  3960. and then save them in the current directory with ":mkexrc!".
  3961.  
  3962.  
  3963. 19.3 Options summary
  3964.  
  3965. In the list below all the options are mentioned with their full name and some
  3966. with an abbreviation between parens. Both forms may be used. In this
  3967. document when an option that can be toggled is "set" that means that ":set
  3968. option" is entered.  When an option is "reset", ":set nooption" is used.
  3969.  
  3970. autoindent (ai)        toggle    (default off)
  3971.     Copy indent from current line when starting a new line (typing <CR> 
  3972.     in Insert mode or when using the "o" or "O" command). If you do not 
  3973.     type anything on the new line except <BS> and then type <ESC> or 
  3974.     <CR>, the indent is deleted again. When autoindent is set, 
  3975.     formatting (with the "Q" command or when you reach 'textwidth' in 
  3976.     Insert mode) uses the indentation of the first line. The 'autoindent'
  3977.     option is reset when the 'paste' option is set.
  3978.  
  3979. autowrite (aw)        toggle    (default off)
  3980.     Write the contents of the file, if it has been modified, on each
  3981.     :next, :rewind, :previous, :stop, :suspend, :tag, :!, :make, CTRL-]
  3982.     and CTRL-^ command; and when a CTRL-O, CTRL-I, '<A-Z>, or `<A-Z>
  3983.     command takes one to another file.
  3984.  
  3985. backspace (bs)        number    (default 0)
  3986.     Influences the working of <BS>, <DEL>, CTRL-W and CTRL-U in Insert 
  3987.     mode. If set to 0 Vi compatible backspacing is used. When 1 allow 
  3988.     backspacing over newlines. When larger than 1 allow backspacing over 
  3989.     the start of insert. In the last case CTRL-W and CTRL-U stop once at 
  3990.     the start of insert. {not in Vi}
  3991.  
  3992. backup (bk)        toggle    (default on)
  3993.     Make a backup before overwriting a file. Leave it around after the 
  3994.     file has been successfully written. If you do not want to keep the 
  3995.     backup file, but you do want a backup while the file is being
  3996.     written, reset this option and set the 'writebackup' option. If you
  3997.     do not want a backup file at all reset both options (See the table
  3998.     in section 5.4 for another explanation.). {not in Vi}
  3999.  
  4000. backupdir (bdir)    string    (default "$HOME")
  4001.     Directory name for the backup file. Empty means in same directory as
  4002.     the edited file. If the directory name starts with <>>, only the
  4003.     specified directory will be used. If there is a directory name but
  4004.     it does not start with <>>, the current directory is tried first.
  4005.     The specified directory is used only if that fails. The name may end
  4006.     in an <:> or </>. Environment variables are expanded. {not in Vi}
  4007.  
  4008. binary (bin)        toggle    (default off)
  4009.     This option should be set before editing a binary file. You can also
  4010.     use the "-b" command line option. When this option is set the
  4011.     'textwidth' option will set to 0, the 'textmode' and 'textauto'
  4012.     options will be reset and 'modelines' will be set to 0. When writing
  4013.     a file the end-of-line for the last line is only written if there
  4014.     was one in the original file (normally Vim appends an end-of-line to
  4015.     the last line if there is none; this would make the file longer). See
  4016.     the 'endofline' option. {not in Vi}
  4017.  
  4018. bioskey (bk)        toggle    (default on)
  4019.     For MSDOS only: When set the bios is called to obtain a keyboard
  4020.     character. This works better to detect CTRL-C, but only works for
  4021.     the console. When using a terminal over a serial port reset this
  4022.     option. {not in Vi}
  4023.  
  4024. cmdheight (ch)        number    (default 1)
  4025.     Number of lines to use for the command line. If you are annoyed by
  4026.     "hit return to continue" or "--more--" caused by long messages, set
  4027.     this option to a larger value. {not in Vi}
  4028.  
  4029. columns            number    (default 80 or terminal width)
  4030.     Number of columns in the display. Normally this is set by the 
  4031.     terminal initialization and does not have to be set by hand. {not in 
  4032.     Vi}
  4033.  
  4034. compatible (cp)        toggle    (default off)
  4035.     At the moment this option is set, several other options will be set 
  4036.     or reset to make Vim vi-compatible. Switching this option off has no 
  4037.     effect. {not in Vi}
  4038.  
  4039.     option        new value    effect
  4040.  
  4041.     backspace    0        normal backspace
  4042.     backup        off        no backup file
  4043.     digraph        off        no digraphs
  4044.     esckeys        off        no <ESC>-keys in Insert mode
  4045.     expandtab    off        tabs not expanded to spaces
  4046.     history        0        no commandline history
  4047.     insertmode    off        do not start in Insert mode
  4048.     joinspaces    on        insert 2 spaces after period
  4049.     modelines    0        no modelines
  4050.     more        off        no pauses in listings
  4051.     revins        off        no reverse insert
  4052.     ruler        off        no ruler
  4053.     scrolljump    0        no jump scroll
  4054.     shiftround    off        indent not rounded to shiftwidth
  4055.     showcmd        off        command characters not shown
  4056.     showmode    off        current mode not shown
  4057.     smartindent    off        no smart indentation
  4058.     textauto    off        no automatic textmode detection
  4059.     textwidth    0        no automatic line wrap
  4060.     tildeop        off        tilde is not an operator
  4061.     ttimeout    off        no terminal timeout
  4062.     undolevels    0        no multilevel undo
  4063.     updatecount    0        no swap file
  4064.     writebackup    off        no backup file written
  4065.     yankendofline    off        do not Yank to end of line
  4066.  
  4067. digraph (dg)        toggle    (default off)
  4068.     Enable the entering of digraphs in Insert mode with {char1} <BS> 
  4069.     {char2}. Only works if Vim was compiled with digraphs enabled. {not 
  4070.     in Vi}
  4071.  
  4072. directory (dir)        string    (default for Amiga: "t:", for MSDOS:
  4073.                 "c:\tmp", for unix: "/tmp")
  4074.     Directory name for the swap file. Empty means in same directory as the
  4075.     edited file. If the directory name starts with <>>, only the
  4076.     specified directory will be used. If there is a directory name but
  4077.     it does not start with <>>, the current directory is tried first.
  4078.     The specified directory is used only if that fails. The name may end
  4079.     in an <:> or </>. Environment variables are expanded. Careful with
  4080.     <\> characters, type two to get one in the option, ":set
  4081.     dir=c:\\tmp". {Vi: directory to put temp file in, defaults to
  4082.     "/tmp"}
  4083.  
  4084. edcompatible        toggle    (default off)
  4085.     Makes the 'g' and 'c' flags of the ":substitute" command to be
  4086.     toggled each time the flag is given. See 11.3. See also 'gdefault'
  4087.     option.
  4088.  
  4089. endofline (eol)        toggle    (default on)
  4090.     When writing a file and this option is off and the 'binary' option is
  4091.     set, no end of line (newline) character will be written for the last
  4092.     line in the file. This option is automatically set when starting to
  4093.     edit a new file, unless the 'binary' options is set and the file does
  4094.     not have an end of line (newline) for the last line in the file, in
  4095.     which case it is reset. Normally you don't have to set or reset this
  4096.     option. When 'binary' is not set the value is not used. When 'binary'
  4097.     is set it is used to remember the presence of a newline for the last
  4098.     line in the file, so that when you write the file the situation from
  4099.     the original file can be kept. But you can change it when you want to.
  4100.     {not in Vi}
  4101.  
  4102. equalalways (ea)    toggle    (default on)
  4103.     When set all the windows are automatically made the same size after
  4104.     splitting or closing a window. If you don't set this option, splitting
  4105.     a window will reduce the size of the current window and leave the
  4106.     other windows the same. When closing a window the extra lines are
  4107.     given the the window above it. {not in Vi}
  4108.  
  4109. equalprg (ep)        string    (default "indent")
  4110.     External program to use for "=" command. Environment variables are
  4111.     expanded. {not in Vi}
  4112.  
  4113. errorbells (eb)        toggle    (default off)
  4114.     Ring the bell for error messages. Does not work on the Amiga, you 
  4115.     always get a screen flash.
  4116.  
  4117. errorfile (ef)        string    (default "AztecC.Err" or "errors")
  4118.     Name of the error file for the QuickFix mode (see 5.5). Environment
  4119.     variables are expanded. {not in Vi}
  4120.  
  4121. errorformat (efm)    string    (default "%f>%l:%c:%t:%n:%m" or
  4122.                         ""%f",%*[^0-9]%l %m")
  4123.     Scanf-like description of the format for the lines in the error file
  4124.     (see 5.5). {not in Vi}
  4125.  
  4126. esckeys (ek)        toggle    (default on)
  4127.     Function keys that start with an <ESC> are recognized in Insert
  4128.     mode. When this option is off, the cursor and function keys cannot be
  4129.     used in Insert mode if they start with an <ESC>. The advantage of this
  4130.     is that the single <ESC> is recognized immediately, instead of after
  4131.     one second.
  4132.  
  4133. expandtab (et)        toggle    (default off)
  4134.     In Insert mode: Use the appropriate number of spaces to insert a 
  4135.     <TAB>. Spaces are used in indents with the '>' and '<' commands and
  4136.     when 'autoindent' is set. To insert a real tab when expandtab is
  4137.     set, use CTRL-V<TAB>. {not in Vi}
  4138.  
  4139. exrc            toggle (default off)
  4140.     Enables the reading of .vimrc and .exrc in the current directory. If
  4141.     you switch this option on you should also consider setting the
  4142.     'secure' option (see 3.4). {not in Vi}
  4143.  
  4144. formatprg (fp)        string (default "")
  4145.     The name of an external program that will be used to format the
  4146.     lines selected with the "Q" command. The program must take the input
  4147.     on stdin and produce the output on stdout. The unix program 'fmt' is
  4148.     such a program. If this option is an empty string, the internal
  4149.     format function will be used. Environment variables are expanded.
  4150.     {not in Vi}
  4151.  
  4152. gdefault (gd)        toggle    (default off)
  4153.     When set, the ":substitute" flag 'g' is default on. This means that
  4154.     all matches in a line are substituted instead of one. See 11.3. {not
  4155.     in Vi} 
  4156.  
  4157. graphic (gr)        toggle    (default off, MSDOS: on)
  4158.     When off characters between <~> and 0xa0 are displayed as "~?", 
  4159.     "~@", "~A", etc.. When on the characters are sent to the display 
  4160.     directly. This will allow for graphic characters to be shown on some 
  4161.     terminals (e.g. MSDOS console) and mess up the display on others 
  4162.     (e.g. Amiga).
  4163.  
  4164. helpfile (hf)        string    (default (Amiga) "vim:vim.hlp"
  4165.                      (unix) "/usr/local/lib/vim.hlp")
  4166.     Name of the help file. It may start with an environment variable. 
  4167.     For example: "$VIM/doc/vim.hlp". Environment variables are expanded.
  4168.     {not in Vi}
  4169.  
  4170. hidden (hid)        toggle    (default off)
  4171.     When off the current buffer is unloaded when it is abandoned. When
  4172.     on the current buffer becomes hidden when starting to edit another
  4173.     buffer. If the current buffer is also displayed in another window it
  4174.     does not become hidden. The commands that move through the buffer
  4175.     list make the current buffer hidden although the 'hidden' option is
  4176.     not set. See also 'windows.doc'. {not in Vi} 
  4177.  
  4178. highlight (hl)        string    (default "db,es,hs,rs,vi,si")
  4179.     This option can be used to set highlighting mode for various
  4180.     occasions. It is a comma separated list of character pairs. The first
  4181.     character in a pair gives the occasion, the second the mode to use for
  4182.     that occasion. The occasions are:
  4183.         v    visual mode
  4184.         d    directories in CTRL-D listing
  4185.         e    error messages
  4186.         s    status lines
  4187.         h    help file headers
  4188.         r    return to continue message and yes/no questions
  4189.     The display modes are:
  4190.         i    invert        (termcap entry "mr")
  4191.         b    bold        (termcap entry "md")
  4192.         s    standout    (termcap entry "so")
  4193.         n    no highlighting
  4194.     The default is to use bold for directories, standout for error
  4195.     messages, help file headers and return, invert for visual mode and
  4196.     status lines.
  4197.     Invert is used for occasions that are not included. {not in Vi}
  4198.  
  4199. history (hi)        number    (default 20)
  4200.     Number of command lines that are remembered. {not in Vi}
  4201.  
  4202. icon            toggle    (default off)
  4203.     When set the icon of the window will be set to the name of the file
  4204.     currently being edited. Only the last part of the name is used. Only
  4205.     works if the terminal supports setting window icons (currently only
  4206.     Unix xterm and iris-ansi). When Vim was compiled with USE_X11
  4207.     defined, the original icon will be restored if possible. {not in Vi}
  4208.  
  4209. ignorecase (ic)        toggle    (default off)
  4210.     Ignore case in search patterns. Also used when searching in the tags
  4211.     file.
  4212.  
  4213. insertmode (im)        toggle    (default off)
  4214.     Start the edit of a file in Insert mode. {not in Vi}
  4215.  
  4216. joinspaces (js)        toggle    (default on)
  4217.     Insert two spaces after a period with a join command. {not in Vi}
  4218.  
  4219. keywordprg (kp)        string    (default "ref")
  4220.     Program to use for the "K" command. Environment variables are
  4221.     expanded. {not in Vi}
  4222.  
  4223. laststatus (ls)        number    (default 1)
  4224.     The value of this option influences when the last window will have a
  4225.     status line:
  4226.         0: never
  4227.         1: only if there are at least two windows
  4228.         2: always
  4229.     The screen looks nicer with a status line if you have several
  4230.     windows, but it takes another screen line. {not in Vi}
  4231.  
  4232. lines            number    (default 24 or terminal height)
  4233.     Number of lines in the display. Normally you don't need to set this. 
  4234.     That is done automatically by the terminal initialization code.
  4235.  
  4236. list            toggle    (default off)
  4237.     List mode: Show tabs as CTRL-I, show end of line with $. Useful to 
  4238.     see the difference between tabs and spaces and for trailing blanks.
  4239.  
  4240. magic            toggle    (default on)
  4241.     Changes the special characters that can be used in search patterns. 
  4242.     See section "Pattern searches".
  4243.  
  4244. makeprg (mp)        string    (default "make")
  4245.     Program to use for the ":make" command. This option may contain
  4246.     <%> and <#> characters, which are expanded like when used in a
  4247.     command line. Environment variables are expanded. {not in Vi}
  4248.  
  4249. maxmem (mm)        number    (default 512)
  4250.     Maximum amount of memory (in Kbyte) to use for one buffer. When this
  4251.     limit is reached allocating extra memory for a buffer will cause
  4252.     other memory to be freed. See also 'maxmemtot'. {not in Vi}
  4253.  
  4254. maxmemtot (mmt)        number    (default 512)
  4255.     Maximum amount of memory (in Kbyte) to use for all buffers together.
  4256.     Added 'maxmemtot' option ('mmt'), maximal Kbyte to use for
  4257.     all buffers.
  4258.  
  4259. modeline (ml)        toggle    (default on)
  4260. modelines (mls)        number    (default 5)
  4261.     If 'modeline' is set 'modelines' gives the number of lines that is
  4262.     checked for set commands. If 'modeline' is not set or 'modelines' is
  4263.     0 no lines are checked. See 19.1. {not in Vi}
  4264.  
  4265. more            toggle    (default on)
  4266.     Listings pause when the whole screen is filled. Type <CR> for one
  4267.     more line. Type <SPACE> for the next page. Type 'q' to stop the
  4268.     listing. When this option is off there are no pauses, the listing
  4269.     continues until finished. When Vim was compiled with COMPATIBLE
  4270.     defined this option is default off. When 'compatible' is set this
  4271.     option is off. {not in Vi}
  4272.  
  4273. nobuf (nb)        toggle    (default off)
  4274.     When set characters are send to the terminal one by one. For MSDOS
  4275.     pcterm this does not work. For debugging purposes. {not in Vi}
  4276.  
  4277. number (nu)        toggle    (default off)
  4278.     Print the line number in front of each line.
  4279.  
  4280. paragraphs (para)    string    (default "IPLPPPQPP LIpplpipbp")
  4281.     Specifies the nroff macros that separate paragraphs. These are pairs 
  4282.     of two letters (see section 6.4).
  4283.  
  4284. paste            toggle    (default off)
  4285.     Put Vim in Paste mode. This is useful if you want to cut or copy
  4286.     some text from one window and paste it in Vim. This will avoid
  4287.     unexpected effects. When the 'paste' option is set mapping in Insert
  4288.     mode is disabled, abbreviations are disabled and some options are
  4289.     reset ('textwidth', 'autoindent', 'smartindent', 'revins', 'ruler'
  4290.     and 'showmatch'). When the 'paste' option is reset the mentioned
  4291.     options are restored to the value before the moment 'paste' was
  4292.     set. Resetting 'paste' before ever setting it does not have any
  4293.     effect. If you use this often, you could map a function key to the
  4294.     command ":set invpaste^V^M". {not in Vi}
  4295.  
  4296. patchmode (pm)        string    (default "")
  4297.     Only for Unix: When set the oldest version of a file is kept. This can
  4298.     be used to keep the original version of a file if you are changing
  4299.     files in a source distribution. Only the first time that a file is
  4300.     edited a copy of the original file will be kept. The name of the copy
  4301.     is the name of the original file with the string in the 'patchmode'
  4302.     option appended. This option should start with a dot. Use a string
  4303.     like ".org". Only works properly if the 'backup' or the 'writebackup'
  4304.     option is set. If both are not set, an empty file is created with the
  4305.     'patchmode' option appended to the name of the original file. This
  4306.     means that you can only see which files where changed. {not in Vi}
  4307.  
  4308. readonly (ro)        toggle    (default off)
  4309.     If set, writes fail unless you use an !. Protects you from
  4310.     accidentally overwriting a file. Also, sets 'updatecount' to zero so
  4311.     that no ".swp" swap file is created. Default on when vim is started
  4312.     in view mode ("vim -v") or when the executable is called "view". It
  4313.     is reset if you overwrite the current file (e.g. with ":w!").
  4314.  
  4315. remap            toggle    (default on)
  4316.     Allows for :map command to work recursively. If you do not want this 
  4317.     for a single entry, use the :noremap[!] command.
  4318.  
  4319. report            number    (default 2)
  4320.     Threshold for reporting number of lines changed.
  4321.  
  4322. revins            toggle    (default off)
  4323.     Inserting characters in Insert mode will work backwards. See "typing
  4324.     backwards". Can be toggled with the CTRL-B command in Insert mode.
  4325.     This option is reset when 'compatible' or 'paste' is set. {not in Vi}
  4326.  
  4327. ruler (ru)        toggle    (default off)
  4328.     Show the line and column number of the cursor position in the status
  4329.     line, separated by a comma. If there are characters in the line that
  4330.     take two positions on the screen, both the "real" column and the
  4331.     screen column are shown, separated with a dash. This option is reset
  4332.     when the 'paste' option is set. {not in Vi}
  4333.  
  4334. scroll            number    (default 'lines' / 2)
  4335.     Number of lines to scroll with CTRL-U and CTRL-D commands. Will be
  4336.     set to half the number of lines in the window when the window size
  4337.     changes. If you give a count to the CTRL-U or CTRL-D command it will
  4338.     be used as the new value for 'scroll'. Reset to 'lines' / 2 with
  4339.     ":set scroll=0".
  4340.  
  4341. scrolljump        number    (default 1)
  4342.     Minimal number of lines to scroll when the cursor gets off the 
  4343.     screen (e.g. with "j"). Not used for scroll commands (e.g. CTRL-E, 
  4344.     CTRL-D). Useful if your terminal scrolls very slowly. {not in Vi}
  4345.  
  4346. sections (sect)        string    (default "SHNHH HUnhsh")
  4347.     Specifies the nroff macros that separate sections. These are pairs of
  4348.     two letters (See section 6.4).
  4349.  
  4350. secure            toggle    (default off)
  4351.     When on, shell and write commands are not allowed in ".vimrc" and 
  4352.     ".exrc" in the current directory and map commands are displayed.
  4353.     Switch it off only if you know that you will not run into problems,
  4354.     or when the 'exrc' option is off. On unix this option is only used
  4355.     if the ".vimrc" or ".exrc" is not owned by you.
  4356.  
  4357. shell (sh)        string    (default $SHELL or "sh", MSDOS: "command")
  4358.     Name of the shell to use for ! and :! commands. See also the
  4359.     'shelltype' option. It is allowed to give an argument to the 
  4360.     command, e.g. "csh -f". If you type this in the command line you 
  4361.     will have to put a backslash in front of the space. Environment
  4362.     variables are expanded.
  4363.  
  4364. shellpipe (sp)        string    (default ">", "| tee", "|& tee" or "2>&1| tee")
  4365.     String to be used to put the output of the ":make" command in the
  4366.     error file. For the Amiga and MSDOS the default is ">". The output
  4367.     is directly saved in a file and not echoed to the screen. For Unix
  4368.     the default it "| tee". The stdout of the compiler is saved in a
  4369.     file and echoed to the screen. If the 'shell' option is "csh" during
  4370.     initializations, the default becomes "|& tee". If the 'shell' option
  4371.     is "sh", "ksh" or "bash" the default becomes "2>&1| tee". This means
  4372.     that stderr is also included. Setting the 'shell' option does not
  4373.     automatically change the 'shellpipe' option.
  4374.  
  4375. shelltype (st)        number    (default 0)
  4376.     On the Amiga this option influences the way how the commands work 
  4377.     which use a shell.
  4378.     0 and 1: always use the shell
  4379.     2 and 3: use the shell only to filter lines
  4380.     4 and 5: use shell only for ':sh' command
  4381.     When not using the shell, the command is executed directly.
  4382.  
  4383.     0 and 2: use 'shell -c cmd' to start external commands
  4384.     1 and 3: use 'shell cmd' to start external commands
  4385.  
  4386. shiftround (sr)        toggle    (default off)
  4387.     Round indent to multiple of shiftwidth. Applies to > and < commands 
  4388.     and to CTRL-T and CTRL-D in Insert mode. {not in Vi}
  4389.  
  4390. shiftwidth (sw)        number    (default 8)
  4391.     Number of spaces to use for (auto)indent.
  4392.  
  4393. shortname (sn)        toggle    (default off)
  4394.     Filenames can be 8 characters plus one extension of 3 characters. 
  4395.     Multiple dots in file names are not allowed. When this option is on, 
  4396.     dots in filenames are replaced by underscores when adding an 
  4397.     extension (".bak" or ".swp"). This option is not available for 
  4398.     MSDOS, because then it would always be on. This option is useful 
  4399.     when editing files on an MSDOS compatible filesystem, e.g. messydos 
  4400.     or crossdos. {not in Vi}
  4401.  
  4402. showcmd (sc)        toggle    (default on, off for unix)
  4403.     show command in status line. Set this option off if your terminal 
  4404.     is slow. {not in Vi}
  4405.  
  4406. showmatch (sm)        toggle    (default off)
  4407.     When a bracket is inserted, briefly jump to the matching one. This
  4408.     option is reset when the 'paste' option is set.
  4409.  
  4410. showmode (smd)        toggle    (default on)
  4411.     If in Insert or Replace mode, put a message on the last line.
  4412.  
  4413. sidescroll (ss)        number    (default 0)
  4414.     The minimal number of columns to scroll horizontally. Used only when
  4415.     the 'wrap' option is on and the cursor is moved off of the screen.
  4416.     When set to zero the cursor will be put in the middle of the screen.
  4417.     When using a slow terminal set it to a large number or 0. When using
  4418.     a fast terminal use a small number or 1. {not in Vi}
  4419.  
  4420. smartindent (si)    toggle    (default off)
  4421.     Do smart autoindenting for C programs in Insert mode and with the
  4422.     "o" and "O" commands. An indent is automatically inserted:
  4423.     - After a line ending in <{>.
  4424.     - After a line starting with "if", "for", "while", "else" or "do".
  4425.       If you type a <{> as the first character in the new line, the
  4426.       indent is deleted. 
  4427.     - Before a line starting with <}> (only with the "O" command).
  4428.     When typing <}> as the first character in a new line, that line is
  4429.     given the same indent as the matching <{>.
  4430.     When typing <#> as the first character in a new line, the indent for
  4431.     that line is removed, the <#> is put in the first column. The indent
  4432.     is restored for the next line.
  4433.     When using the ">>" command, lines starting with <#> are not shifted
  4434.     right.
  4435.     'smartindent' is reset when the 'paste' option is set. {not in Vi}
  4436.  
  4437. smarttab (sta)        toggle    (default off)
  4438.     When set a TAB in front of a line inserts 'shiftwidth' positions,
  4439.     'tabstop' in other places. When not set a TAB always inserts 'tabstop'
  4440.     positions, 'shiftwidth' is only used for ">>" and the like. {not in
  4441.     Vi}
  4442.  
  4443. splitbelow (sb)        toggle    (default off)
  4444.     When set new window from split is below the current one. {not in Vi}
  4445.  
  4446. suffixes (su)        string    (default ".bak.o.h.info.swp")
  4447.     Files with these suffixes are ignored when multiple files match a
  4448.     wildcard. {not in Vi}
  4449.  
  4450. tabstop (ts)        number    (default 8)
  4451.     Number of spaces that a <TAB> in the file counts for.
  4452.  
  4453. taglength (tl)        number    (default 0)
  4454.     If non-zero, tags are significant up to this number of characters.
  4455.  
  4456. tagrelative (tr)    toggle    (default on)
  4457.     If set and using a tag file in another directory, file names in that
  4458.     tag file are relative to the directory where the tag file is. If Vim
  4459.     was compiled with COMPATIBLE defined, or when the 'compatible' option
  4460.     is set, this option is reset. {not in Vi}
  4461.  
  4462. tags            string    (default "tags")
  4463.     Filenames for the tag command, separated by spaces. Environment
  4464.     variables are expanded for the first name. {Vi: default is "tags
  4465.     /usr/lib/tags"}
  4466.  
  4467. term            string    (default $TERM or "amiga" on Amiga, "pcterm"
  4468.                     on MSDOS)
  4469.     Name of the terminal. Used for choosing the terminal control 
  4470.     characters. Environment variables are expanded.
  4471.  
  4472. terse            toggle    (default off)
  4473.     Shorten some of the messages. {Vi shortens a lot more messages}
  4474.  
  4475. textauto (ta)        toggle    (default on)
  4476.     When a new file is edited the first line is checked for the line
  4477.     separator. If it is a single <LF> 'textmode' is reset. If it is a
  4478.     <CR><LF> pair 'textmode' is set. {not in Vi}
  4479.  
  4480. textmode (tx)        toggle    (MSDOS: default on, others: default off)
  4481.     When off, <LF> separates lines. When on, <CR><LF> separates lines
  4482.     and CTRL-Z at end of file is ignored. Only used when reading and
  4483.     writing files. Set automatically when reading a file and 'textauto'
  4484.     is on. {not in Vi}
  4485.  
  4486. textwidth        number    (default 0)
  4487.     Maximum width of text that is being inserted. A longer line will be
  4488.     broken after white space to get this width. A zero value disables
  4489.     this. 'textwidth' is set to 0 when the 'paste' option is set. When
  4490.     'textwidth' is zero, 'wrapmargin' may be used. {not in Vi} 
  4491.  
  4492. tildeop (to)        toggle    (default off)
  4493.     The tilde command <~> behaves like an operator. {not in Vi}
  4494.  
  4495. timeout            toggle (default on)
  4496. ttimeout        toggle (default off)
  4497.     These two options together determine the behaviour when part of a 
  4498.     mapped key sequence or keyboard code has been received:
  4499.  
  4500.     timeout        ttimeout    action
  4501.     off        off        no time out
  4502.     on        on or off    time out on :mappings and key codes
  4503.     off        on        time out on key codes
  4504.  
  4505.     If there is no time out, Vim will wait until either the complete 
  4506.     mapping or key sequence has been received, or it is clear that there 
  4507.     is no mapping or key sequence for the received characters. For 
  4508.     example: if you have mapped "vl" and Vim has received <v>, the next 
  4509.     character is needed to see if the <v> is followed by an <l>. With a 
  4510.     time out Vim will wait for about 1 second for the next character to 
  4511.     arrive. After that the already received characters are interpreted
  4512.     as single characters. The time can be set with the 'timeoutlen'
  4513.     option.
  4514.     On slow terminals or very busy systems time out may cause 
  4515.     malfunctioning cursor keys. If both options are off, Vim waits 
  4516.     forever after an entered <ESC> if there are key codes that start 
  4517.     with <ESC>. You will have to type <ESC> twice. If you do not have 
  4518.     problems with key codes, but would like to have :mapped key 
  4519.     sequences not time out in 1 second, set the ttimeout option and 
  4520.     reset the timeout option. {the ttimeout option is not in Vi}
  4521.  
  4522. timeoutlen (tm)        number    (default 1000)
  4523.     The time in milliseconds that is waited for a key code or mapped key
  4524.     sequence to complete. {only in some versions of Vi}
  4525.  
  4526. title            toggle    (default on)
  4527.     When set the title of the window will be set to "VIM - filename",
  4528.     where filename is the name of the file currently being edited. Only
  4529.     works if the terminal supports setting window titles (currently Amiga
  4530.     console, Unix xterm and iris-ansi). When Vim was compiled with NOTITLE
  4531.     defined the default is off. When Vim was compiled with USE_X11
  4532.     defined, the original title will be restored if possible. {not in Vi}
  4533.  
  4534. ttyfast    (tf)        toggle (default off)
  4535.     Indicates a fast terminal connection. More characters will be send
  4536.     to the screen for redrawing, instead of using insert/delete line
  4537.     commands. Improves smoothness of redrawing when there are multiple
  4538.     windows and the terminal does not support a scrolling region. {not
  4539.     in Vi} 
  4540.  
  4541. undolevels (ul)        number    (default 100)
  4542.     Maximum number of changes that can be undone. Set to 0 for Vi 
  4543.     compatibility: one level of undo and 'u' undoes itself. Set to a
  4544.     negative number for no undo at all (saves memory). {not in Vi}
  4545.  
  4546. updatecount (uc)    number    (default 200)
  4547.     After this many characters typed the swap file will be written to
  4548.     disk. When zero the swap script will not be written at all (see
  4549.     chapter on recovery). {not in Vi}
  4550.  
  4551. updatetime (ut)        number    (default 4000)
  4552.     If this many milliseconds nothing is typed the swap file will be
  4553.     written to disk (see chapter on recovery). {not in Vi}
  4554.  
  4555. visualbell (vb)        toggle    (default off)
  4556.     Use (sort of) visual bell for AUX device. {not in Vi}
  4557.  
  4558. warn            toggle    (default on)
  4559.     Give a warning message when a shell command is used while the buffer
  4560.     has been changed.
  4561.  
  4562. weirdinvert (wi)    toggle    (default off)
  4563.     Set this option for terminals that have a weird inversion method.
  4564.     Makes the start/end invert code outputted before every character.
  4565.     Slows down terminal I/O a lot, but it makes Visual mode work.
  4566.     {not in Vi}
  4567.  
  4568. whichwrap (ww)        number    (default 3)
  4569.     Allow specified keys that move the cursor left/right to wrap to the
  4570.     previous/next line when the cursor is on the first/last character in
  4571.     the line. Add numbers to allow this for these keys:
  4572.          1 for backspace     in command mode
  4573.          2 for space         in command mode
  4574.          4 for 'h' and 'l'     in command mode
  4575.          8 for cursor left/right in command mode
  4576.         16 for cursor left/right in insert mode
  4577.     For example: ":set ww=24" allows wrap only when cursor keys are used.
  4578.     When compiled with COMPATIBLE defined or when 'compatible' option set,
  4579.     'whichwrap' is set to 0.
  4580.     {not in Vi}
  4581.  
  4582. wildchar (wc)        number    (default <TAB> or CTRL-E)
  4583.     Character you have to type to start wildcard expansion in the 
  4584.     command line. CTRL-E is used when Vim was compiled with COMPATIBLE 
  4585.     or when the 'compatible' option is set. The character is not
  4586.     recognized when used inside a macro. {not in Vi}
  4587.  
  4588. winheight (wh)        number    (default 0)
  4589.     Minimal number of lines for the current window. If the current
  4590.     window is smaller, its size is increased, at the cost of the height
  4591.     of other windows. Set it to 999 to make the current window always
  4592.     fill the screen. Set it to a small number for normal editing. The
  4593.     height is not adjusted after one of the commands to change the
  4594.     height of the current window. {not in Vi} 
  4595.  
  4596. wrap            toggle    (default on)
  4597.     When on, long lines will wrap and continue on the next line. When
  4598.     off long lines will not wrap and only part of them will be shown.
  4599.     When the cursor is moved to a part that is not shown, the screen
  4600.     will scroll horizontally (also see 'sidescroll' option. {not in Vi}
  4601.  
  4602. wrapmargin (wm)        number    (default 0)
  4603.     Number of characters from the right window border where wrapping
  4604.     starts. When 'textwidth' is set, this option is not used. {Vi: works
  4605.     differently and less useful}
  4606.  
  4607. wrapscan (ws)        toggle    (default on)
  4608.     Searches wrap around the end of the file.
  4609.  
  4610. writeany (wa)        toggle    (default off)
  4611.     Allows writing to any file with no need for "!" override.
  4612.  
  4613. writebackup (wb)    toggle    (default on)
  4614.     Make a backup before overwriting a file. The backup is removed after 
  4615.     the file was successfully written, unless the 'backup' option is also 
  4616.     on. {not in Vi}
  4617.  
  4618. yankendofline (ye)    toggle    (default off)
  4619.     The Y command yanks from the cursor until the end of the line instead
  4620.     of whole lines. {not in Vi}
  4621.  
  4622.  
  4623.     20. Terminal information
  4624.  
  4625. Vim uses information about the terminal you are using to fill the screen and 
  4626. recognize what keys you hit. If this information is not correct the screen 
  4627. may be messed up or keys may not be recognized. The actions which have to be 
  4628. performed on the screen are accomplished by outputting a string of
  4629. characters. Special keys produce a string of characters. These strings are 
  4630. stored in the terminal options, see section 20.2.
  4631.  
  4632.  
  4633. 20.1 startup
  4634.  
  4635. When Vim is started a default terminal type is assumed. For the Amiga this 
  4636. is a standard CLI window, for MSDOS the pc terminal, for Unix an ansi 
  4637. terminal. A few other terminal types are always available. Use the command 
  4638. "set term=xxx" to find out which ones are builtin.
  4639.  
  4640. You can give the terminal name with the '-T' command line option. If it is 
  4641. not given Vim will try to get the name from the TERM environment variable.
  4642.  
  4643. On Unix the termcap file is used. On Amiga and MSDOS this is only available 
  4644. if Vim was compiled with TERMCAP defined. If the termcap code is included 
  4645. Vim will try to get the strings for the terminal you are using from the 
  4646. termcap file.
  4647.  
  4648. For normal editing the terminal will be put into "raw" mode. The strings 
  4649. defined with 't_ts' and 't_ks' will be sent to the terminal. Normally this 
  4650. puts the terminal in a state where the termcap codes are valid and activates 
  4651. the cursor and function keys. When Vim exits the terminal will be put back 
  4652. into the mode it was before Vim started. The strings defined with 't_te' and 
  4653. 't_ke' will be sent to the terminal. On the Amiga with commands that execute
  4654. an external command (e.g. "!!") the terminal will be put into normal mode
  4655. for a moment. This means that you can stop the output to the screen by
  4656. hitting a printing key. Output resumes when you hit <BS>.
  4657.  
  4658. Some termcap entries are wrong in the sense that after sending 't_ks' the 
  4659. cursor keys send codes different from the codes defined in the termcap. To 
  4660. avoid this you can set 't_ks' (and 't_ke') to empty strings. This must be
  4661. done during initialization (see 3.4), otherwise its too late.
  4662.  
  4663. Some termcap entries assume that the highest bit is always reset. For 
  4664. example: The cursor-up entry for the amiga could be ":ku=\EA:". But the 
  4665. Amiga really sends "\233A". This works fine if the highest bit is reset, 
  4666. e.g. when using an Amiga over a serial line. If the cursor keys don't work, 
  4667. try the entry ":ku=\233A:".
  4668.  
  4669. Some termcap entries have the entry ":ku=\E[A:". But the Amiga really sends 
  4670. "\233A". On output "\E[" and "\233" are often equivalent, on input they 
  4671. aren't. You will have to change the termcap entry, or change the key code 
  4672. with the :set command to fix this.
  4673.  
  4674. Many cursor key codes start with an <ESC>. Vim must find out if this a 
  4675. single hit of the <ESC> key or the start of a cursor key sequence. It waits 
  4676. for a next character to arrive. If it does not arrive within one second a 
  4677. single <ESC> is assumed. On very slow systems this may fail, causing cursor 
  4678. keys not to work sometimes. If you discover this problem reset the 'timeout' 
  4679. option. Vim will wait for the next character to arrive after an <ESC>. If 
  4680. you want to enter a single <ESC> you must type it twice. Resetting the
  4681. 'esckeys' option avoids this problems in Insert mode, but you lose the
  4682. possibility to use cursor and function keys in Insert mode.
  4683.  
  4684. On the Amiga the recognition of window resizing is activated only when the 
  4685. terminal name is "amiga" or "builtin_amiga".
  4686.  
  4687. Some terminals have confusing codes for the cursor keys. The televideo 925
  4688. is such a terminal. It sends a CTRL-H for cursor-left. This would make it
  4689. impossible to distinguish a backspace and cursor-left. To avoid this problem
  4690. CTRL-H is never recognized as cursor-left.
  4691.  
  4692.  
  4693. 20.2 terminal options
  4694.  
  4695. The terminal options can be set just like normal options. But they are not
  4696. shown with the ":set all" command. Instead use ":set termcap".
  4697.  
  4698. It is always possible to change individual strings by setting the 
  4699. appropriate option. For example:
  4700.  
  4701.     :set t_el=^V^[[K    (CTRL-V, ESC, [, K)
  4702.  
  4703. {Vi: no terminal options. You have to exit vi, edit the termcap entry and
  4704. try again}
  4705.  
  4706. The options are listed below along with the associated termcap code. Two of
  4707. them are required: Cursor positioning and clear screen. The others are used
  4708. to minimize the screen updating overhead and to recognize special keys.
  4709.  
  4710.  
  4711.     option    termcap        meaning
  4712.  
  4713. OUTPUT CODES
  4714.     t_name    (name)    name of current terminal entry
  4715.     t_el    ce    clear to end of line
  4716.     t_il    al    add new blank line
  4717.     t_cil    AL    add number of blank lines
  4718.     t_dl    dl    delete line
  4719.     t_cdl    DL    delete number of lines
  4720.     t_cs    cs    define scrolling region
  4721.     t_ed    cl    clear screen (required!)
  4722.     t_ci    vi    cursor invisible
  4723.     t_cv    ve    cursor visible
  4724.     t_cvv    cvv    cursor very visible
  4725.     t_tp    me    normal mode (undoes t_ti and t_tb)
  4726.     t_ti    mr    reverse (invert) mode
  4727.     t_tb    md    bold mode
  4728.     t_se    se    standout end
  4729.     t_so    so    standout mode
  4730.     t_ms    ms    if set, cursor can be moved in standout/inverse mode
  4731.     t_cm    cm    cursor motion (required!)
  4732.     t_sr    sr    scroll reverse (backward)
  4733.     t_cri    RI    cursor number of chars right
  4734.     t_vb    vb    visual bell
  4735.     t_ks    ks    put terminal in "keypad transmit" mode
  4736.     t_ke    ke    out of "keypad transmit" mode
  4737.     t_ts    ti    put terminal in "termcap" mode
  4738.     t_te    te    out of "termcap" mode
  4739.  
  4740. KEY CODES
  4741.     t_ku    ku    arrow up
  4742.     t_kd    kd    arrow down
  4743.     t_kr    kr    arrow right
  4744.     t_kl    kl    arrow left
  4745.     t_sku    (none)    shift arrow up
  4746.     t_skd    (none)    shift arrow down
  4747.     t_skr    %i    shift arrow right
  4748.     t_skl    #4    shift arrow left
  4749.     t_f1    k1    function key 1
  4750.     t_f2    k2    function key 2
  4751.     t_f3    k3    function key 3
  4752.     t_f4    k4    function key 4
  4753.     t_f5    k5    function key 5
  4754.     t_f6    k6    function key 6
  4755.     t_f7    k7    function key 7
  4756.     t_f8    k8    function key 8
  4757.     t_f9    k9    function key 9
  4758.     t_f10    k;    function key 10
  4759.     t_sf1    F1    function key 11 or shifted function key 1
  4760.     t_sf2    F2    function key 12 or shifted function key 2
  4761.     t_sf3    F3    function key 13 or shifted function key 3
  4762.     t_sf4    F4    function key 14 or shifted function key 4
  4763.     t_sf5    F5    function key 15 or shifted function key 5
  4764.     t_sf6    F6    function key 16 or shifted function key 6
  4765.     t_sf7    F7    function key 17 or shifted function key 7
  4766.     t_sf8    F8    function key 18 or shifted function key 8
  4767.     t_sf9    F9    function key 19 or shifted function key 9
  4768.     t_sf10    FA    function key 20 or shifted function key 10
  4769.     t_help    %1    help key
  4770.     t_undo    &8    undo key
  4771.  
  4772. Note about t_so and t_ti: When the termcap entry "so" is not present the
  4773. entry for "mr" is used. And visa versa. The same is done for "se" and "me".
  4774. If your terminal supports both inversion and standout mode, you can see two
  4775. different modes. If you terminal supports only one of the modes, both will
  4776. look the same.
  4777.  
  4778. If inversion or other highlighting does not work correctly, try setting the
  4779. 'weirdinvert' option. This makes the start-highlight or end-highlight termcap
  4780. code to be outputted before every character. This slows down terminal I/O a
  4781. lot, but it makes inversion work on some terminals.
  4782.  
  4783. Some termcaps do not include an entry for 'cs' (scroll region), although the
  4784. terminal does support it. For example: xterm on a sun. You can use the
  4785. builtin_xterm or define t_cs yourself. For example:
  4786.  
  4787.     :set t_cs=^V^[[%i%d;%dr
  4788.  
  4789. Where ^V is CTRL-V and ^[ is <ESC>.
  4790.  
  4791. Unfortunately it is not possible to deduct from the termcap how cursor
  4792. positioning should be done when using a scrolling region: Relative to the
  4793. beginning of the screen or relative to the beginning of the scrolling region.
  4794. Most terminals use the first method. A know exception is the MSDOS console
  4795. (pcterm). The 't_csc' option should be set to any string when cursor
  4796. positioning is relative to the start of the scrolling region. It should be set
  4797. to an empty string otherwise. It is default "yes" when 'term' is "pcterm".
  4798.  
  4799. Note for xterm users: The shifted cursor keys normally don't work. You can
  4800.     make them work with the xmodmap command and some mappings in Vim.
  4801.  
  4802.     Give these commands in the xterm:
  4803.         xmodmap -e "keysym Up = Up F16"
  4804.         xmodmap -e "keysym Down = Down F17"
  4805.         xmodmap -e "keysym Left = Left F18"
  4806.         xmodmap -e "keycode Right = Right F19"
  4807.  
  4808.     And use these mappings in Vim:
  4809.         :map CTRL-V 151 CTRL-V 132
  4810.         :map! CTRL-V 151 CTRL-V 132
  4811.         :map CTRL-V 152 CTRL-V 133
  4812.         :map! CTRL-V 152 CTRL-V 133
  4813.         :map CTRL-V 153 CTRL-V 134
  4814.         :map! CTRL-V 153 CTRL-V 134
  4815.         :map CTRL-V 154 CTRL-V 135
  4816.         :map! CTRL-V 154 CTRL-V 135
  4817.  
  4818. Where 151-154 are the internal vim decimal codes for function keys F16 to
  4819. F19 and 132-135 are the codes for the shifted arrow keys.
  4820.  
  4821.  
  4822. 20.3 Window size
  4823.  
  4824. [This is about the size of the whole window Vim is using, not a window that is
  4825. created with the :split command]
  4826.  
  4827. If you are running Vim on an Amiga and the terminal name is "amiga" or 
  4828. "builtin_amiga", the amiga-specific window resizing will be enabled. On Unix 
  4829. systems three methods are tried to get the window size:
  4830.  
  4831. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  4832. - the environment variables "LINES" and "COLUMNS"
  4833. - from the termcap entries "li" and "co"
  4834.  
  4835. If everything fails a default size of 24 lines and 80 columns is assumed. If 
  4836. a window-resize signal is received the size will be set again. If the window 
  4837. size is wrong you can use the 'lines' and 'columns' options to set the 
  4838. correct values.
  4839.  
  4840. One command can be used to set the screen size:
  4841.  
  4842. :mode [mode]
  4843.  
  4844. Without argument this only detects the screen size. With MSDOS it is possible
  4845. to switch screen mode. [mode] can be one of these values:
  4846.     "bw40"        40 columns black&white
  4847.     "c40"        40 columns color
  4848.     "bw80"        80 columns black&white
  4849.     "c80"        80 columns black&white (most people use this)
  4850.     "mono"        80 columns monochrome
  4851.     "c4350"        43 or 50 lines EGA/VGA mode
  4852.     number        mode number to use, depends on your video card
  4853.  
  4854.  
  4855. 20.4 slow and fast terminals
  4856.  
  4857. If you have a fast terminal you may like to set the 'ruler' option. The 
  4858. cursor position is shown in the status line. If you are using horizontal
  4859. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  4860. number. 
  4861.  
  4862. If you have a slow terminal you may want to reset the 'showcmd' option. 
  4863. The command characters will not be shown in the status line. If the terminal 
  4864. scrolls very slowly, set the 'scrolljump' to 5 or so. If the cursor is moved
  4865. off the screen (e.g. with "j") Vim will scroll 5 lines at a time. Another
  4866. possibility is to reduce the number of lines that Vim uses with the command
  4867. "z<height><CR>".
  4868.  
  4869. If the characters from the terminal are arriving with more than 1 second 
  4870. between them you might want to set the 'timeout' and/or 'ttimeout' option. 
  4871. See the "Options" chapter.
  4872.  
  4873. If your terminal does not support a scrolling region, but it does support
  4874. insert/delete line commands, scrolling with multiple windows may make the
  4875. lines jump up and down. If you don't want this set the 'ttyfast' option.
  4876. This will redraw the window instead of scroll it.
  4877.  
  4878. If you are testing termcap options, but you cannot see what is happening,
  4879. you might want to set the 'nobuf' option ('nb'). When set one character is
  4880. send to the terminal at a time (does not work for MSDOS). This makes the
  4881. screen updating a lot slower, making it possible to see what is happening.
  4882.  
  4883.  
  4884.     21. Differences from Vi and Ex
  4885.  
  4886. Throughout this document differences between Vim and Vi/Ex are given in
  4887. curly braces. This chapter only lists what has not been mentioned in
  4888. previous chapters. Also see "difference.doc" for an overview.
  4889.  
  4890.  
  4891. 21.1 Missing commands
  4892.  
  4893. A large number of the "Ex" commands (the commands that start with a colon) 
  4894. are included. However, there is no Ex mode. 
  4895.  
  4896. These commands are in Vi, but not in Vim.
  4897.  
  4898. Q            {Vi: go to Ex mode}
  4899.  
  4900. :a[ppend]        {Vi: append text}
  4901. :c[hange]        {Vi: replace lines}
  4902. :i[nsert]        {Vi: insert text}
  4903. :o[pen]            {Vi: start editing in open mode}
  4904. :rec[over]        {Vi: recover a file after a crash or :preserve}
  4905. :z            {Vi: print some lines}
  4906.  
  4907.  
  4908. 21.2 Missing options
  4909.  
  4910. These options are in the unix Vi, but not in Vim. If you try to set one of
  4911. them you won't get an error message, but the value is not used and cannot be
  4912. printed.
  4913.  
  4914. autoprint (ap)        toggle    (default on)
  4915. beautify (bf)        toggle    (default off)
  4916. hardtabs (ht)        number    (default 8)
  4917.     number of spaces that a <TAB> moves on the display
  4918. lisp            toggle    (default off)
  4919. mesg            toggle    (default on)
  4920. open            toggle    (default on)
  4921. optimize (op)        toggle    (default on)
  4922. prompt            toggle    (default on)
  4923. redraw            toggle    (default off)
  4924. slowopen (slow)        toggle    (default off)
  4925. sourceany        toggle    (default not documented)
  4926. ttytype            string
  4927. window            number    (default 24)
  4928. w300            number    (default 24)
  4929. w1200            number    (default 24)
  4930. w9600            number    (default 24)
  4931.  
  4932.  
  4933.  
  4934. CONTENTS
  4935.  
  4936. [Note: The commands for multiple windows and buffers are explained in
  4937. windows.doc]
  4938.  
  4939.  1. Introduction
  4940.  2. Notation
  4941.  3. Starting Vim
  4942.     3.1 Command line
  4943.     3.2 Workbench (Amiga only)
  4944.     3.3 Vim window (Amiga only)
  4945.     3.4 Initialization
  4946.     3.5 Suspending
  4947.  4. Modes
  4948.     4.1 Introduction
  4949.     4.2 Switching from mode to mode
  4950.     4.3 Insert and Replace mode
  4951.         4.3.1 special keys
  4952.         4.3.2 special special keys
  4953.         4.3.3 'textwidth' option
  4954.         4.3.4 'expandtab' option
  4955.         4.3.5 typing backwards
  4956.         4.3.6 Replace mode
  4957.         4.3.7 Keyword completion
  4958.     4.4 Command_line mode
  4959.         4.4.1 Command line editing
  4960.         4.4.2 Command line completion
  4961.         4.4.3 Ex command lines
  4962.         4.4.4 Ex command line ranges
  4963.     4.5 The window contents
  4964.     4.6 Abbreviations
  4965.     4.7 Digraphs
  4966.  5. Editing files
  4967.     5.1 Introduction
  4968.     5.2 Editing a file
  4969.     5.3 The argument list
  4970.     5.4 Writing and quitting
  4971.     5.5 Using the QuickFix mode
  4972.     5.6 Editing binary files
  4973.  6. Cursor motions
  4974.     6.1 Left-right motions
  4975.     6.2 Up-down motions
  4976.     6.3 Word motions
  4977.     6.4 Text object motions
  4978.     6.5 Pattern searches
  4979.     6.6 Various motions
  4980.  7. Scrolling
  4981.  8. Tags
  4982.  9. Inserting text
  4983. 10. Deleting text
  4984. 11. Changing text
  4985.     11.1 Delete and insert
  4986.     11.2 Simple changes
  4987.     11.3 Complex changes
  4988. 12. Copying and moving text
  4989. 13. Visual mode
  4990. 14. Various commands
  4991. 15. Repeating commands
  4992.     15.1 Single repeats
  4993.     15.2 Multiple repeats
  4994.     15.3 Complex repeats
  4995. 16. Undo and redo
  4996. 17. Key mapping
  4997. 18. Recovery after a crash
  4998.     18.1 The swap file
  4999.     18.2 Recovery
  5000. 19. Options
  5001.     19.1 Setting options
  5002.     19.2 Saving settings
  5003.     19.3 Options summary
  5004. 20. Terminal information
  5005.     20.1 startup
  5006.     20.2 terminal options
  5007.     20.3 Window size
  5008.     20.4 slow and fast terminals
  5009. 21. Differences from Vi and Ex
  5010.     21.1 Missing commands
  5011.     21.2 Missing options
  5012.  
  5013. vim:tw=76:ts=8:sw=8
  5014.